From 40a7b8879cbd47dec809d5f2a11a0baaaae57841 Mon Sep 17 00:00:00 2001 From: Dmitry Serov Date: Sat, 8 Jul 2017 16:16:01 +0700 Subject: [PATCH] NSArray subscripting --- macosx/AddMagnetWindowController.m | 2 +- macosx/AddWindowController.m | 2 +- macosx/Controller.m | 42 ++++++++++++++--------------- macosx/CreatorWindowController.m | 12 ++++----- macosx/FileListNode.m | 2 +- macosx/FileOutlineController.m | 2 +- macosx/GroupToolbarItem.m | 6 ++--- macosx/GroupsController.m | 32 +++++++++++----------- macosx/GroupsPrefsController.m | 2 +- macosx/InfoActivityViewController.m | 4 +-- macosx/InfoFileViewController.m | 12 ++++----- macosx/InfoGeneralViewController.m | 6 ++--- macosx/InfoPeersViewController.m | 12 ++++----- macosx/InfoTrackersViewController.m | 20 +++++++------- macosx/InfoWindowController.m | 2 +- macosx/MessageWindowController.m | 6 ++--- macosx/NSMutableArrayAdditions.m | 8 +++--- macosx/PrefsController.m | 18 ++++++------- macosx/Torrent.m | 8 +++--- macosx/TorrentTableView.m | 2 +- macosx/TrackerCell.m | 2 +- macosx/TrackerTableView.m | 6 ++--- 22 files changed, 104 insertions(+), 104 deletions(-) diff --git a/macosx/AddMagnetWindowController.m b/macosx/AddMagnetWindowController.m index fe7d5d5f6..345c09c43 100644 --- a/macosx/AddMagnetWindowController.m +++ b/macosx/AddMagnetWindowController.m @@ -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) diff --git a/macosx/AddWindowController.m b/macosx/AddWindowController.m index 796ba7c99..bdc3d656b 100644 --- a/macosx/AddWindowController.m +++ b/macosx/AddWindowController.m @@ -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 { diff --git a/macosx/Controller.m b/macosx/Controller.m index a553d4c1d..f2ebb59da 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -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 ) 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 diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 54069e939..582582ec2 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -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; } diff --git a/macosx/FileListNode.m b/macosx/FileListNode.m index b8f0b9aae..2b77be02b 100644 --- a/macosx/FileListNode.m +++ b/macosx/FileListNode.m @@ -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) diff --git a/macosx/FileOutlineController.m b/macosx/FileOutlineController.m index 5318eb41c..54e9057ad 100644 --- a/macosx/FileOutlineController.m +++ b/macosx/FileOutlineController.m @@ -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 diff --git a/macosx/GroupToolbarItem.m b/macosx/GroupToolbarItem.m index e02983336..4db2d4949 100644 --- a/macosx/GroupToolbarItem.m +++ b/macosx/GroupToolbarItem.m @@ -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; } diff --git a/macosx/GroupsController.m b/macosx/GroupsController.m index a36506ab2..5c18e5290 100644 --- a/macosx/GroupsController.m +++ b/macosx/GroupsController.m @@ -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: diff --git a/macosx/GroupsPrefsController.m b/macosx/GroupsPrefsController.m index 654b6c3ce..152c54abc 100644 --- a/macosx/GroupsPrefsController.m +++ b/macosx/GroupsPrefsController.m @@ -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]; } diff --git a/macosx/InfoActivityViewController.m b/macosx/InfoActivityViewController.m index 8d192363e..282c6161a 100644 --- a/macosx/InfoActivityViewController.m +++ b/macosx/InfoActivityViewController.m @@ -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]; diff --git a/macosx/InfoFileViewController.m b/macosx/InfoFileViewController.m index 872629f6e..6a034f4cd 100644 --- a/macosx/InfoFileViewController.m +++ b/macosx/InfoFileViewController.m @@ -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]; } diff --git a/macosx/InfoGeneralViewController.m b/macosx/InfoGeneralViewController.m index 01a7e197b..bb6aefa97 100644 --- a/macosx/InfoGeneralViewController.m +++ b/macosx/InfoGeneralViewController.m @@ -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], diff --git a/macosx/InfoPeersViewController.m b/macosx/InfoPeersViewController.m index 224c5fbc7..fcb623833 100644 --- a/macosx/InfoPeersViewController.m +++ b/macosx/InfoPeersViewController.m @@ -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"])) diff --git a/macosx/InfoTrackersViewController.m b/macosx/InfoTrackersViewController.m index 0edabb04f..1eff4ad77 100644 --- a/macosx/InfoTrackersViewController.m +++ b/macosx/InfoTrackersViewController.m @@ -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]) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 835a87d20..b10dbf806 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -480,7 +480,7 @@ typedef enum } else { - Torrent * torrent = [fTorrents objectAtIndex: 0]; + Torrent * torrent = fTorrents[0]; [fImageView setImage: [torrent icon]]; diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 4ebe3fcc1..8c1788d1f 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -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"]; } diff --git a/macosx/NSMutableArrayAdditions.m b/macosx/NSMutableArrayAdditions.m index 4a66aa92c..16f723245 100644 --- a/macosx/NSMutableArrayAdditions.m +++ b/macosx/NSMutableArrayAdditions.m @@ -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]; } diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index aee6cd159..2072df99e 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -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]; } diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 2b55d98d4..b32a62362 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -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 diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 27025b952..248ff62c6 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -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"]; } diff --git a/macosx/TrackerCell.m b/macosx/TrackerCell.m index e4e8ce942..69d9e8bb0 100644 --- a/macosx/TrackerCell.m +++ b/macosx/TrackerCell.m @@ -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]; diff --git a/macosx/TrackerTableView.m b/macosx/TrackerTableView.m index b52440769..181dc01f1 100644 --- a/macosx/TrackerTableView.m +++ b/macosx/TrackerTableView.m @@ -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