NSArray subscripting

This commit is contained in:
Dmitry Serov 2017-07-08 16:16:01 +07:00
parent b743b64262
commit 40a7b8879c
22 changed files with 104 additions and 104 deletions

View File

@ -190,7 +190,7 @@
[panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
[self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType:TorrentDeterminationUserSpecified];
[self setDestinationPath: [[panel URLs][0] path] determinationType:TorrentDeterminationUserSpecified];
else
{
if (!fDestination)

View File

@ -181,7 +181,7 @@
if (result == NSFileHandlingPanelOKButton)
{
fLockDestination = YES;
[self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType: TorrentDeterminationUserSpecified];
[self setDestinationPath: [[panel URLs][0] path] determinationType: TorrentDeterminationUserSpecified];
}
else
{

View File

@ -1472,7 +1472,7 @@ static void removeKeRangerRansomware()
const NSUInteger selected = [torrents count];
if (selected == 1)
{
NSString * torrentName = [(Torrent *)[torrents objectAtIndex: 0] name];
NSString * torrentName = [(Torrent *)torrents[0] name];
if (deleteData)
title = [NSString stringWithFormat:
@ -1594,7 +1594,7 @@ static void removeKeRangerRansomware()
//if not removed from the displayed torrents here, fullUpdateUI might cause a crash
if ([fDisplayedTorrents count] > 0)
{
if ([[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [TorrentGroup class]])
if ([fDisplayedTorrents[0] isKindOfClass: [TorrentGroup class]])
{
for (TorrentGroup * group in fDisplayedTorrents)
doTableRemoval([group torrents], group);
@ -1642,7 +1642,7 @@ static void removeKeRangerRansomware()
NSString * message, * info;
if ([torrents count] == 1)
{
NSString * torrentName = [(Torrent *)[torrents objectAtIndex: 0] name];
NSString * torrentName = [(Torrent *)torrents[0] name];
message = [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove \"%@\" from the transfer list?",
"Remove completed confirm panel -> title"), torrentName];
@ -1694,7 +1694,7 @@ static void removeKeRangerRansomware()
NSInteger count = [torrents count];
if (count == 1)
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\".",
"Move torrent -> select destination folder"), [(Torrent *)[torrents objectAtIndex: 0] name]]];
"Move torrent -> select destination folder"), [(Torrent *)torrents[0] name]]];
else
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for %d data files.",
"Move torrent -> select destination folder"), count]];
@ -1703,7 +1703,7 @@ static void removeKeRangerRansomware()
if (result == NSFileHandlingPanelOKButton)
{
for (Torrent * torrent in torrents)
[torrent moveTorrentDataFileTo: [[[panel URLs] objectAtIndex: 0] path]];
[torrent moveTorrentDataFileTo: [[panel URLs][0] path]];
}
}];
}
@ -1721,7 +1721,7 @@ static void removeKeRangerRansomware()
return;
}
Torrent * torrent = [torrents objectAtIndex: 0];
Torrent * torrent = torrents[0];
if (![torrent isMagnet] && [[NSFileManager defaultManager] fileExistsAtPath: [torrent torrentLocation]])
{
@ -1799,7 +1799,7 @@ static void removeKeRangerRansomware()
{
NSArray * selected = [fTableView selectedTorrents];
NSAssert([selected count] == 1, @"1 transfer needs to be selected to rename, but %ld are selected", [selected count]);
Torrent * torrent = [selected objectAtIndex:0];
Torrent * torrent = selected[0];
[FileRenameSheetController presentSheetForTorrent:torrent modalForWindow: fWindow completionHandler: ^(BOOL didRename) {
if (didRename)
@ -1961,7 +1961,7 @@ static void removeKeRangerRansomware()
if (filtering)
{
NSUInteger count = [fTableView numberOfRows]; //have to factor in collapsed rows
if (count > 0 && ![[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [Torrent class]])
if (count > 0 && ![fDisplayedTorrents[0] isKindOfClass: [Torrent class]])
count -= [fDisplayedTorrents count];
totalTorrentsString = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "Status bar transfer count"),
@ -2353,7 +2353,7 @@ static void removeKeRangerRansomware()
for (NSUInteger currentIndex = 1; currentIndex < [rearrangeArray count]; ++currentIndex)
{
//manually do the sorting in-place
const NSUInteger insertIndex = [rearrangeArray indexOfObject: [rearrangeArray objectAtIndex: currentIndex] inSortedRange: NSMakeRange(0, currentIndex) options: (NSBinarySearchingInsertionIndex | NSBinarySearchingLastEqual) usingComparator: ^NSComparisonResult(id obj1, id obj2) {
const NSUInteger insertIndex = [rearrangeArray indexOfObject: rearrangeArray[currentIndex] inSortedRange: NSMakeRange(0, currentIndex) options: (NSBinarySearchingInsertionIndex | NSBinarySearchingLastEqual) usingComparator: ^NSComparisonResult(id obj1, id obj2) {
for (NSSortDescriptor * descriptor in descriptors)
{
const NSComparisonResult result = [descriptor compareObject: obj1 toObject: obj2];
@ -2488,8 +2488,8 @@ static void removeKeRangerRansomware()
[fFilterBar setCountAll: [fTorrents count] active: active downloading: downloading seeding: seeding paused: paused];
//if either the previous or current lists are blank, set its value to the other
const BOOL groupRows = [allTorrents count] > 0 ? [fDefaults boolForKey: @"SortByGroup"] : ([fDisplayedTorrents count] > 0 && [[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [TorrentGroup class]]);
const BOOL wasGroupRows = [fDisplayedTorrents count] > 0 ? [[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [TorrentGroup class]] : groupRows;
const BOOL groupRows = [allTorrents count] > 0 ? [fDefaults boolForKey: @"SortByGroup"] : ([fDisplayedTorrents count] > 0 && [fDisplayedTorrents[0] isKindOfClass: [TorrentGroup class]]);
const BOOL wasGroupRows = [fDisplayedTorrents count] > 0 ? [fDisplayedTorrents[0] isKindOfClass: [TorrentGroup class]] : groupRows;
#warning could probably be merged with later code somehow
//clear display cache for not-shown torrents
@ -2586,14 +2586,14 @@ static void removeKeRangerRansomware()
const NSUInteger originalGroupCount = [fDisplayedTorrents count];
for (NSUInteger index = 0; index < originalGroupCount; ++index)
{
TorrentGroup * group = [fDisplayedTorrents objectAtIndex: index];
TorrentGroup * group = fDisplayedTorrents[index];
NSMutableIndexSet * removeIndexes = [NSMutableIndexSet indexSet];
//needs to be a signed integer
for (NSUInteger indexInGroup = 0; indexInGroup < [[group torrents] count]; ++indexInGroup)
{
Torrent * torrent = [[group torrents] objectAtIndex: indexInGroup];
Torrent * torrent = [group torrents][indexInGroup];
const NSUInteger allIndex = [allTorrents indexOfObjectAtIndexes: unusedAllTorrentsIndexes options: NSEnumerationConcurrent passingTest: ^(id obj, NSUInteger idx, BOOL * stop) {
return (BOOL)(obj == torrent);
}];
@ -2994,9 +2994,9 @@ static void removeKeRangerRansomware()
- (id) outlineView: (NSOutlineView *) outlineView child: (NSInteger) index ofItem: (id) item
{
if (item)
return [[item torrents] objectAtIndex: index];
return [item torrents][index];
else
return [fDisplayedTorrents objectAtIndex: index];
return fDisplayedTorrents[index];
}
- (BOOL) outlineView: (NSOutlineView *) outlineView isItemExpandable: (id) item
@ -3144,7 +3144,7 @@ static void removeKeRangerRansomware()
Torrent * topTorrent = nil;
for (NSInteger i = newRow-1; i >= 0; i--)
{
Torrent * tempTorrent = [groupTorrents objectAtIndex: i];
Torrent * tempTorrent = groupTorrents[i];
if (![movingTorrents containsObject: tempTorrent])
{
topTorrent = tempTorrent;
@ -3247,7 +3247,7 @@ static void removeKeRangerRansomware()
{
if (!fOverlayWindow)
fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
[fOverlayWindow setFile: [[files objectAtIndex: 0] lastPathComponent]];
[fOverlayWindow setFile: [files[0] lastPathComponent]];
return NSDragOperationCopy;
}
@ -3303,7 +3303,7 @@ static void removeKeRangerRansomware()
else
{
if (!torrent && [files count] == 1)
[CreatorWindowController createTorrentFile: fLib forFile: [NSURL fileURLWithPath: [files objectAtIndex: 0]]];
[CreatorWindowController createTorrentFile: fLib forFile: [NSURL fileURLWithPath: files[0]]];
else
accept = NO;
}
@ -3656,9 +3656,9 @@ static void removeKeRangerRansomware()
- (id <QLPreviewItem>) previewPanel: (QLPreviewPanel *) panel previewItemAtIndex: (NSInteger) index
{
if ([fInfoController canQuickLook])
return [[fInfoController quickLookURLs] objectAtIndex: index];
return [fInfoController quickLookURLs][index];
else
return [[self quickLookableTorrents] objectAtIndex: index];
return [self quickLookableTorrents][index];
}
- (BOOL) previewPanel: (QLPreviewPanel *) panel handleEvent: (NSEvent *) event
@ -4517,7 +4517,7 @@ static void removeKeRangerRansomware()
- (NSRect) sizedWindowFrame
{
NSUInteger groups = ([fDisplayedTorrents count] > 0 && ![[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [Torrent class]])
NSUInteger groups = ([fDisplayedTorrents count] > 0 && ![fDisplayedTorrents[0] isKindOfClass: [Torrent class]])
? [fDisplayedTorrents count] : 0;
CGFloat heightChange = (GROUP_SEPARATOR_HEIGHT + [fTableView intercellSpacing].height) * groups

View File

@ -129,7 +129,7 @@
//remove potentially invalid addresses
for (NSInteger i = [fTrackers count]-1; i >= 0; i--)
{
if (!tr_urlIsValidTracker([[fTrackers objectAtIndex: i] UTF8String]))
if (!tr_urlIsValidTracker([fTrackers[i] UTF8String]))
[fTrackers removeObjectAtIndex: i];
}
}
@ -326,7 +326,7 @@
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
{
return [fTrackers objectAtIndex: row];
return fTrackers[row];
}
- (IBAction) addRemoveTracker: (id) sender
@ -369,7 +369,7 @@
[fTrackers removeObjectAtIndex: row];
}
else
[fTrackers replaceObjectAtIndex: row withObject: tracker];
fTrackers[row] = tracker;
[fTrackerTable deselectAll: self];
[fTrackerTable reloadData];
@ -467,7 +467,7 @@
[panel setMessage: NSLocalizedString(@"Select a file or folder for the torrent file.", "Create torrent -> select file")];
BOOL success = [panel runModal] == NSOKButton;
return success ? [[panel URLs] objectAtIndex: 0] : nil;
return success ? [panel URLs][0] : nil;
}
- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
@ -519,7 +519,7 @@
NSLocalizedString(@"A file with the name \"%@\" already exists in the directory \"%@\". "
"Choose a new name or directory to create the torrent file.",
"Create torrent -> file already exists warning -> warning"),
[pathComponents objectAtIndex: count-1], [pathComponents objectAtIndex: count-2]]];
pathComponents[count-1], pathComponents[count-2]]];
[alert setAlertStyle: NSWarningAlertStyle];
[alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
@ -531,7 +531,7 @@
for (NSUInteger i = 0; i < [fTrackers count]; i++)
{
trackerInfo[i].announce = (char *)[[fTrackers objectAtIndex: i] UTF8String];
trackerInfo[i].announce = (char *)[fTrackers[i] UTF8String];
trackerInfo[i].tier = i;
}

View File

@ -140,7 +140,7 @@
{
lookupPathComponents = [lookupPathComponents arrayByAddingObject: oldName];
const BOOL allSame = NSNotFound == [lookupPathComponents indexOfObjectWithOptions: NSEnumerationConcurrent passingTest: ^BOOL(NSString * name, NSUInteger idx, BOOL * stop) {
return ![name isEqualToString: [thesePathComponents objectAtIndex: idx]];
return ![name isEqualToString: thesePathComponents[idx]];
}];
if (allSame)

View File

@ -233,7 +233,7 @@ typedef enum
- (id) outlineView: (NSOutlineView *) outlineView child: (NSInteger) index ofItem: (id) item
{
return [(item ? [(FileListNode *)item children] : fFileList) objectAtIndex: index];
return (item ? [(FileListNode *)item children] : fFileList)[index];
}
- (id) outlineView: (NSOutlineView *) outlineView objectValueForTableColumn: (NSTableColumn *) tableColumn byItem: (id) item

View File

@ -42,7 +42,7 @@
for (NSInteger i = 0; i < [control segmentCount]; i++)
[control setEnabled: [[self target] validateToolbarItem:
[[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]] forSegment: i];
[[[NSToolbarItem alloc] initWithItemIdentifier: fIdentifiers[i]] autorelease]] forSegment: i];
}
- (void) createMenu: (NSArray *) labels
@ -56,7 +56,7 @@
const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
for (NSInteger i = 0; i < count; i++)
{
NSMenuItem * addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
NSMenuItem * addItem = [[NSMenuItem alloc] initWithTitle: labels[i] action: [self action] keyEquivalent: @""];
[addItem setTarget: [self target]];
[addItem setTag: i];
@ -76,7 +76,7 @@
const NSInteger count = [(NSSegmentedControl *)[self view] segmentCount];
for (NSInteger i = 0; i < count; i++)
[[[menuItem submenu] itemAtIndex: i] setEnabled: [[self target] validateToolbarItem:
[[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]]];
[[[NSToolbarItem alloc] initWithItemIdentifier: fIdentifiers[i]] autorelease]]];
return menuItem;
}

View File

@ -121,7 +121,7 @@ GroupsController * fGroupsInstance = nil;
if (index != -1)
{
for (NSUInteger i = 0; i < [fGroups count]; i++)
if (index == [[[fGroups objectAtIndex: i] objectForKey: @"Index"] integerValue])
if (index == [[fGroups[i] objectForKey: @"Index"] integerValue])
return i;
}
return -1;
@ -129,19 +129,19 @@ GroupsController * fGroupsInstance = nil;
- (NSInteger) indexForRow: (NSInteger) row
{
return [[[fGroups objectAtIndex: row] objectForKey: @"Index"] integerValue];
return [[fGroups[row] objectForKey: @"Index"] integerValue];
}
- (NSString *) nameForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"Name"] : nil;
return orderIndex != -1 ? [fGroups[orderIndex] objectForKey: @"Name"] : nil;
}
- (void) setName: (NSString *) name forIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
[[fGroups objectAtIndex: orderIndex] setObject: name forKey: @"Name"];
[fGroups[orderIndex] setObject: name forKey: @"Name"];
[self saveGroups];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
@ -150,19 +150,19 @@ GroupsController * fGroupsInstance = nil;
- (NSImage *) imageForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [self imageForGroup: [fGroups objectAtIndex: orderIndex]]
return orderIndex != -1 ? [self imageForGroup: fGroups[orderIndex]]
: [NSImage imageNamed: @"GroupsNoneTemplate"];
}
- (NSColor *) colorForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"Color"] : nil;
return orderIndex != -1 ? [fGroups[orderIndex] objectForKey: @"Color"] : nil;
}
- (void) setColor: (NSColor *) color forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
NSMutableDictionary * dict = fGroups[[self rowValueForIndex: index]];
[dict removeObjectForKey: @"Icon"];
[dict setObject: color forKey: @"Color"];
@ -177,12 +177,12 @@ GroupsController * fGroupsInstance = nil;
return NO;
NSInteger orderIndex = [self rowValueForIndex: index];
return [[[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesCustomDownloadLocation"] boolValue];
return [[fGroups[orderIndex] objectForKey: @"UsesCustomDownloadLocation"] boolValue];
}
- (void) setUsesCustomDownloadLocation: (BOOL) useCustomLocation forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
NSMutableDictionary * dict = fGroups[[self rowValueForIndex: index]];
[dict setObject: @(useCustomLocation) forKey: @"UsesCustomDownloadLocation"];
@ -192,12 +192,12 @@ GroupsController * fGroupsInstance = nil;
- (NSString *) customDownloadLocationForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"CustomDownloadLocation"] : nil;
return orderIndex != -1 ? [fGroups[orderIndex] objectForKey: @"CustomDownloadLocation"] : nil;
}
- (void) setCustomDownloadLocation: (NSString *) location forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
NSMutableDictionary * dict = fGroups[[self rowValueForIndex: index]];
[dict setObject: location forKey: @"CustomDownloadLocation"];
[[GroupsController groups] saveGroups];
@ -209,13 +209,13 @@ GroupsController * fGroupsInstance = nil;
if (orderIndex == -1)
return NO;
NSNumber * assignRules = [[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesAutoGroupRules"];
NSNumber * assignRules = [fGroups[orderIndex] objectForKey: @"UsesAutoGroupRules"];
return assignRules && [assignRules boolValue];
}
- (void) setUsesAutoAssignRules: (BOOL) useAutoAssignRules forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
NSMutableDictionary * dict = fGroups[[self rowValueForIndex: index]];
[dict setObject: @(useAutoAssignRules) forKey: @"UsesAutoGroupRules"];
@ -228,12 +228,12 @@ GroupsController * fGroupsInstance = nil;
if (orderIndex == -1)
return nil;
return [[fGroups objectAtIndex: orderIndex] objectForKey: @"AutoGroupRules"];
return [fGroups[orderIndex] objectForKey: @"AutoGroupRules"];
}
- (void) setAutoAssignRules: (NSPredicate *) predicate forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
NSMutableDictionary * dict = fGroups[[self rowValueForIndex: index]];
if (predicate)
{
@ -265,7 +265,7 @@ GroupsController * fGroupsInstance = nil;
- (void) removeGroupWithRowIndex: (NSInteger) row
{
NSInteger index = [[[fGroups objectAtIndex: row] objectForKey: @"Index"] integerValue];
NSInteger index = [[fGroups[row] objectForKey: @"Index"] integerValue];
[fGroups removeObjectAtIndex: row];
[[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:

View File

@ -211,7 +211,7 @@
const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
if (result == NSFileHandlingPanelOKButton)
{
NSString * path = [[[panel URLs] objectAtIndex: 0] path];
NSString * path = [[panel URLs][0] path];
[[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
[[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
}

View File

@ -159,7 +159,7 @@
if (numberSelected == 1)
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
[fStateField setStringValue: [torrent stateString]];
@ -272,7 +272,7 @@
}
else
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
[fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];

View File

@ -108,7 +108,7 @@
[fFileController refresh];
#warning use TorrentFileCheckChange notification as well
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
if ([torrent isFolder])
{
const NSInteger filesCheckState = [torrent checkForFiles: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [torrent fileCount])]];
@ -141,7 +141,7 @@
- (NSArray *) quickLookURLs
{
FileOutlineView * fileOutlineView = [fFileController outlineView];
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [indexes count]];
@ -160,7 +160,7 @@
if ([fTorrents count] != 1)
return NO;
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
if (![torrent isFolder])
return NO;
@ -179,7 +179,7 @@
FileOutlineView * fileOutlineView = [fFileController outlineView];
NSString * fullPath = [(NSURL *)item path];
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
NSRange visibleRows = [fileOutlineView rowsInRect: [fileOutlineView bounds]];
for (NSUInteger row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
@ -212,7 +212,7 @@
if ([fTorrents count] == 1)
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
[fFileController setTorrent: torrent];
@ -240,7 +240,7 @@
- (BOOL) canQuickLookFile: (FileListNode *) item
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
return ([item isFolder] || [torrent fileProgress: item] >= 1.0) && [torrent fileLocation: item];
}

View File

@ -108,7 +108,7 @@
if ([fTorrents count] != 1)
return;
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
NSString * location = [torrent dataLocation];
[fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
@ -119,7 +119,7 @@
- (void) revealDataFile: (id) sender
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
NSString * location = [torrent dataLocation];
if (!location)
return;
@ -136,7 +136,7 @@
{
if ([fTorrents count] == 1)
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
#warning candidate for localizedStringWithFormat (although then we'll get two commas)
NSString * piecesString = ![torrent isMagnet] ? [NSString stringWithFormat: @"%ld, %@", [torrent pieceCount],

View File

@ -264,7 +264,7 @@
if (tableView == fWebSeedTable)
{
NSString * ident = [column identifier];
NSDictionary * webSeed = [fWebSeeds objectAtIndex: row];
NSDictionary * webSeed = fWebSeeds[row];
if ([ident isEqualToString: @"DL From"])
{
@ -277,7 +277,7 @@
else
{
NSString * ident = [column identifier];
NSDictionary * peer = [fPeers objectAtIndex: row];
NSDictionary * peer = fPeers[row];
if ([ident isEqualToString: @"Encryption"])
return [[peer objectForKey: @"Encryption"] boolValue] ? [NSImage imageNamed: @"Lock"] : nil;
@ -309,7 +309,7 @@
if ([ident isEqualToString: @"Progress"])
{
NSDictionary * peer = [fPeers objectAtIndex: row];
NSDictionary * peer = fPeers[row];
[(PeerProgressIndicatorCell *)cell setSeed: [[peer objectForKey: @"Seed"] boolValue]];
}
}
@ -347,7 +347,7 @@
{
const BOOL multiple = [fTorrents count] > 1;
NSDictionary * peer = [fPeers objectAtIndex: row];
NSDictionary * peer = fPeers[row];
NSMutableArray * components = [NSMutableArray arrayWithCapacity: multiple ? 6 : 5];
if (multiple)
@ -442,7 +442,7 @@
else
{
if ([fTorrents count] > 1)
return [[fWebSeeds objectAtIndex: row] objectForKey: @"Name"];
return [fWebSeeds[row] objectForKey: @"Name"];
}
return nil;
@ -522,7 +522,7 @@
BOOL useSecond = YES, asc = YES;
if ([oldDescriptors count] > 0)
{
NSSortDescriptor * descriptor = [oldDescriptors objectAtIndex: 0];
NSSortDescriptor * descriptor = oldDescriptors[0];
[descriptors addObject: descriptor];
if ((useSecond = ![[descriptor key] isEqualToString: @"IP"]))

View File

@ -104,7 +104,7 @@
NSArray * oldTrackers = fTrackers;
if ([fTorrents count] == 1)
fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
fTrackers = [[fTorrents[0] allTrackerStats] retain];
else
{
fTrackers = [[NSMutableArray alloc] init];
@ -129,7 +129,7 @@
NSArray * tierAndTrackerBeingAdded = [fTrackers objectsAtIndexes: addedIndexes];
[fTrackers release];
fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
fTrackers = [[fTorrents[0] allTrackerStats] retain];
[fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
[fTrackerTable setTrackers: fTrackers];
@ -158,7 +158,7 @@
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (NSInteger) row
{
id item = [fTrackers objectAtIndex: row];
id item = fTrackers[row];
if ([item isKindOfClass: [NSDictionary class]])
{
@ -176,14 +176,14 @@
- (NSCell *) tableView: (NSTableView *) tableView dataCellForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
{
const BOOL tracker = [[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]];
const BOOL tracker = [fTrackers[row] isKindOfClass: [TrackerNode class]];
return tracker ? fTrackerCell : [tableColumn dataCellForRow: row];
}
- (CGFloat) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row
{
//check for NSDictionay instead of TrackerNode because of display issue when adding a row
if ([[fTrackers objectAtIndex: row] isKindOfClass: [NSDictionary class]])
if ([fTrackers[row] isKindOfClass: [NSDictionary class]])
return TRACKER_GROUP_SEPARATOR_HEIGHT;
else
return [tableView rowHeight];
@ -202,13 +202,13 @@
- (BOOL) tableView: (NSTableView *) tableView isGroupRow: (NSInteger) row
{
return ![[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]] && [tableView editedRow] != row;
return ![fTrackers[row] isKindOfClass: [TrackerNode class]] && [tableView editedRow] != row;
}
- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
tableColumn: (NSTableColumn *) column row: (NSInteger) row mouseLocation: (NSPoint) mouseLocation
{
id node = [fTrackers objectAtIndex: row];
id node = fTrackers[row];
if ([node isKindOfClass: [TrackerNode class]])
return [(TrackerNode *)node fullAnnounceAddress];
else
@ -218,7 +218,7 @@
- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
row: (NSInteger) row
{
Torrent * torrent= [fTorrents objectAtIndex: 0];
Torrent * torrent= fTorrents[0];
BOOL added = NO;
for (NSString * tracker in [object componentsSeparatedByString: @"\n"])
@ -278,7 +278,7 @@
}
else
{
[fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
[fTrackerTable setTorrent: fTorrents[0]];
[fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
@ -316,7 +316,7 @@
NSMutableIndexSet * removeIndexes = [NSMutableIndexSet indexSet];
for (NSUInteger i = 0; i < [fTrackers count]; ++i)
{
id object = [fTrackers objectAtIndex: i];
id object = fTrackers[i];
if ([object isKindOfClass: [TrackerNode class]])
{
if (groupSelected || [selectedIndexes containsIndex: i])

View File

@ -480,7 +480,7 @@ typedef enum
}
else
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
Torrent * torrent = fTorrents[0];
[fImageView setImage: [torrent icon]];

View File

@ -263,7 +263,7 @@
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (NSInteger) row
{
NSString * ident = [column identifier];
NSDictionary * message = [fDisplayedMessages objectAtIndex: row];
NSDictionary * message = fDisplayedMessages[row];
if ([ident isEqualToString: @"Date"])
return [message objectForKey: @"Date"];
@ -292,7 +292,7 @@
#warning don't cut off end
- (CGFloat) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row
{
NSString * message = [[fDisplayedMessages objectAtIndex: row] objectForKey: @"Message"];
NSString * message = [fDisplayedMessages[row] objectForKey: @"Message"];
NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"];
const CGFloat count = floorf([message sizeWithAttributes: fAttributes].width / [column width]);
@ -309,7 +309,7 @@
- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
tableColumn: (NSTableColumn *) column row: (NSInteger) row mouseLocation: (NSPoint) mouseLocation
{
NSDictionary * message = [fDisplayedMessages objectAtIndex: row];
NSDictionary * message = fDisplayedMessages[row];
return [message objectForKey: @"File"];
}

View File

@ -34,20 +34,20 @@
if (fromIndex == toIndex)
return;
id object = [[self objectAtIndex: fromIndex] retain];
id object = [self[fromIndex] retain];
//shift objects - more efficient than simply removing the object and re-inserting the object
if (fromIndex < toIndex)
{
for (NSUInteger i = fromIndex; i < toIndex; ++i)
[self replaceObjectAtIndex: i withObject: [self objectAtIndex: i+1]];
self[i] = self[i+1];
}
else
{
for (NSUInteger i = fromIndex; i > toIndex; --i)
[self replaceObjectAtIndex: i withObject: [self objectAtIndex: i-1]];
self[i] = self[i-1];
}
[self replaceObjectAtIndex: toIndex withObject: object];
self[toIndex] = object;
[object release];
}

View File

@ -93,7 +93,7 @@
[fDefaults setObject: blocklistDate forKey: @"BlocklistNewLastUpdate"];
[fDefaults removeObjectForKey: @"BlocklistLastUpdate"];
NSURL * blocklistDir = [[[[NSFileManager defaultManager] URLsForDirectory: NSApplicationDirectory inDomains: NSUserDomainMask] objectAtIndex: 0] URLByAppendingPathComponent: @"Transmission/blocklists/"];
NSURL * blocklistDir = [[[NSFileManager defaultManager] URLsForDirectory: NSApplicationDirectory inDomains: NSUserDomainMask][0] URLByAppendingPathComponent: @"Transmission/blocklists/"];
[[NSFileManager defaultManager] moveItemAtURL: [blocklistDir URLByAppendingPathComponent: @"level1.bin"]
toURL: [blocklistDir URLByAppendingPathComponent: [NSString stringWithUTF8String: DEFAULT_BLOCKLIST_FILENAME]]
error: nil];
@ -838,7 +838,7 @@
{
[fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
NSString * folder = [[[panel URLs] objectAtIndex: 0] path];
NSString * folder = [[panel URLs][0] path];
[fDefaults setObject: folder forKey: @"DownloadFolder"];
[fDefaults setBool: YES forKey: @"DownloadLocationConstant"];
[self updateShowAddMagnetWindowField];
@ -867,7 +867,7 @@
[panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
{
NSString * folder = [[[panel URLs] objectAtIndex: 0] path];
NSString * folder = [[panel URLs][0] path];
[fDefaults setObject: folder forKey: @"IncompleteDownloadFolder"];
assert(folder.length > 0);
@ -890,7 +890,7 @@
[panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
{
NSString * filePath = [[[panel URLs] objectAtIndex: 0] path];
NSString * filePath = [[panel URLs][0] path];
assert(filePath.length > 0);
@ -981,7 +981,7 @@
VDKQueue * watcherQueue = [(Controller *)[NSApp delegate] fileWatcherQueue];
[watcherQueue removeAllPaths];
NSString * path = [[[panel URLs] objectAtIndex: 0] path];
NSString * path = [[panel URLs][0] path];
[fDefaults setObject: path forKey: @"AutoImportDirectory"];
[watcherQueue addPath: [path stringByExpandingTildeInPath] notifyingAbout: VDKQueueNotifyAboutWrite];
@ -1126,7 +1126,7 @@
- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
{
return [fRPCWhitelistArray objectAtIndex: row];
return fRPCWhitelistArray[row];
}
- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
@ -1164,19 +1164,19 @@
newIP = [newComponents componentsJoinedByString: @"."];
//don't allow the same ip address
if ([fRPCWhitelistArray containsObject: newIP] && ![[fRPCWhitelistArray objectAtIndex: row] isEqualToString: newIP])
if ([fRPCWhitelistArray containsObject: newIP] && ![fRPCWhitelistArray[row] isEqualToString: newIP])
valid = false;
}
if (valid)
{
[fRPCWhitelistArray replaceObjectAtIndex: row withObject: newIP];
fRPCWhitelistArray[row] = newIP;
[fRPCWhitelistArray sortUsingSelector: @selector(compareNumeric:)];
}
else
{
NSBeep();
if ([[fRPCWhitelistArray objectAtIndex: row] isEqualToString: @""])
if ([fRPCWhitelistArray[row] isEqualToString: @""])
[fRPCWhitelistArray removeObjectAtIndex: row];
}

View File

@ -559,7 +559,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
* newComponents = [folder pathComponents];
const NSUInteger oldCount = [oldComponents count];
if (oldCount < [newComponents count] && [[newComponents objectAtIndex: oldCount] isEqualToString: [self name]]
if (oldCount < [newComponents count] && [newComponents[oldCount] isEqualToString: [self name]]
&& [folder hasPrefix: oldFolder])
{
NSAlert * alert = [[NSAlert alloc] init];
@ -618,7 +618,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
//if the remaining space is greater than the size left, then there is enough space regardless of preallocation
if (remainingSpace < [self sizeLeft] && remainingSpace < tr_torrentGetBytesLeftToAllocate(fHandle))
{
NSString * volumeName = [[[NSFileManager defaultManager] componentsToDisplayForPath: downloadFolder] objectAtIndex: 0];
NSString * volumeName = [[NSFileManager defaultManager] componentsToDisplayForPath: downloadFolder][0];
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: [NSString stringWithFormat:
@ -1766,7 +1766,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
NSArray * pathComponents = [fullPath pathComponents];
if (!tempNode)
tempNode = [[FileListNode alloc] initWithFolderName:[pathComponents objectAtIndex: 0] path:@"" torrent:self];
tempNode = [[FileListNode alloc] initWithFolderName:pathComponents[0] path:@"" torrent:self];
[self insertPathForComponents: pathComponents withComponentIndex: 1 forParent: tempNode fileSize: file->length index: i flatList: flatFileList];
}
@ -1793,7 +1793,7 @@ bool trashDataFile(const char * filename, tr_error ** error)
NSParameterAssert([components count] > 0);
NSParameterAssert(componentIndex < [components count]);
NSString * name = [components objectAtIndex: componentIndex];
NSString * name = components[componentIndex];
const BOOL isFolder = componentIndex < ([components count]-1);
//determine if folder node already exists

View File

@ -869,7 +869,7 @@
if (row < 0 || [[self itemAtRow: row] isKindOfClass: [Torrent class]])
return NO;
NSString * ident = [[[self tableColumns] objectAtIndex: [self columnAtPoint: point]] identifier];
NSString * ident = [[self tableColumns][[self columnAtPoint: point]] identifier];
return [ident isEqualToString: @"UL"] || [ident isEqualToString: @"UL Image"]
|| [ident isEqualToString: @"DL"] || [ident isEqualToString: @"DL Image"];
}

View File

@ -198,7 +198,7 @@ NSMutableSet * fTrackerIconLoading;
NSString * baseAddress;
if (separable && [hostComponents count] > 1)
baseAddress = [NSString stringWithFormat: @"http://%@.%@",
[hostComponents objectAtIndex: [hostComponents count]-2], [hostComponents lastObject]];
hostComponents[[hostComponents count]-2], [hostComponents lastObject]];
else
baseAddress = [NSString stringWithFormat: @"http://%@", host];

View File

@ -48,11 +48,11 @@
NSIndexSet * indexes = [self selectedRowIndexes];
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
{
id item = [fTrackers objectAtIndex: i];
id item = fTrackers[i];
if (![item isKindOfClass: [TrackerNode class]])
{
for (++i; i < [fTrackers count] && [[fTrackers objectAtIndex: i] isKindOfClass: [TrackerNode class]]; ++i)
[addresses addObject: [(TrackerNode *)[fTrackers objectAtIndex: i] fullAnnounceAddress]];
for (++i; i < [fTrackers count] && [fTrackers[i] isKindOfClass: [TrackerNode class]]; ++i)
[addresses addObject: [(TrackerNode *)fTrackers[i] fullAnnounceAddress]];
--i;
}
else