]> granicus.if.org Git - transmission/commitdiff
NSArray subscripting
authorDmitry Serov <barbari100@gmail.com>
Sat, 8 Jul 2017 09:16:01 +0000 (16:16 +0700)
committerDmitry Serov <barbari100@gmail.com>
Sat, 8 Jul 2017 09:16:01 +0000 (16:16 +0700)
22 files changed:
macosx/AddMagnetWindowController.m
macosx/AddWindowController.m
macosx/Controller.m
macosx/CreatorWindowController.m
macosx/FileListNode.m
macosx/FileOutlineController.m
macosx/GroupToolbarItem.m
macosx/GroupsController.m
macosx/GroupsPrefsController.m
macosx/InfoActivityViewController.m
macosx/InfoFileViewController.m
macosx/InfoGeneralViewController.m
macosx/InfoPeersViewController.m
macosx/InfoTrackersViewController.m
macosx/InfoWindowController.m
macosx/MessageWindowController.m
macosx/NSMutableArrayAdditions.m
macosx/PrefsController.m
macosx/Torrent.m
macosx/TorrentTableView.m
macosx/TrackerCell.m
macosx/TrackerTableView.m

index fe7d5d5f653f5cb134ca6c133d589a824c9051d4..345c09c43c0e9d3d723e2a6f5ee2bd1bff8db35f 100644 (file)
 
     [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)
index 796ba7c990121765a3963a8f07bf139382d94c7e..bdc3d656bd06a059a6edfde64c0e0d4c1d9459b2 100644 (file)
         if (result == NSFileHandlingPanelOKButton)
         {
             fLockDestination = YES;
-            [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType: TorrentDeterminationUserSpecified];
+            [self setDestinationPath: [[panel URLs][0] path] determinationType: TorrentDeterminationUserSpecified];
         }
         else
         {
index a553d4c1d7b69e01f523d8830865585957b932ea..f2ebb59dad325a09c23016c4a5aedaea1254c661 100644 (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
index 54069e939bff6c168b9d43c43d73f67ea248ad00..582582ec280e000bbe60b7d5693a897071c4c884 100644 (file)
         //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];
         }
     }
 
 - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
 {
-    return [fTrackers objectAtIndex: row];
+    return fTrackers[row];
 }
 
 - (IBAction) addRemoveTracker: (id) sender
         [fTrackers removeObjectAtIndex: row];
     }
     else
-        [fTrackers replaceObjectAtIndex: row withObject: tracker];
+        fTrackers[row] = tracker;
 
     [fTrackerTable deselectAll: self];
     [fTrackerTable reloadData];
     [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
                 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];
 
     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;
     }
 
index b8f0b9aae22fc6876b25fdb4e0d7d3acd49b4767..2b77be02b5c969d13d7e9679cf2db5f37b67b701 100644 (file)
     {
         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)
index 5318eb41ceb5c55c6c27dd46de6020d1cac767c6..54e9057adaed77fc4e98516f737f081559e9dcdd 100644 (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
index e02983336911eafee66b5674695c297213b988ce..4db2d4949ea6dfc81a1c872f3707e4ce191c0e18 100644 (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;
 }
index a36506ab207c982173a9f66199bd64a15f31838f..5c18e5290d635cb60235299f4fdc20c7ce79b853 100644 (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:
index 654b6c3ce5b335ef0eb22e635a3f71dc1411d48b..152c54abc54247bda5e37b82c6cd47e36655ffea 100644 (file)
         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];
         }
index 8d192363e9457a0ee130bf11972f19a2400e7205..282c6161aa4256731c2bd8fcc7694cf62f9a6a4b 100644 (file)
 
     if (numberSelected == 1)
     {
-        Torrent * torrent = [fTorrents objectAtIndex: 0];
+        Torrent * torrent = fTorrents[0];
 
         [fStateField setStringValue: [torrent stateString]];
 
     }
     else
     {
-        Torrent * torrent = [fTorrents objectAtIndex: 0];
+        Torrent * torrent = fTorrents[0];
 
         const BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
         [fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
index 872629f6e71589c61ce61ca7e8748452f739eb32..6a034f4cd0553fbbaf8784449f33ffde01d368f4 100644 (file)
         [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])]];
 - (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]];
 
     if ([fTorrents count] != 1)
         return NO;
 
-    Torrent * torrent = [fTorrents objectAtIndex: 0];
+    Torrent * torrent = fTorrents[0];
     if (![torrent isFolder])
         return NO;
 
     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++)
 
     if ([fTorrents count] == 1)
     {
-        Torrent * torrent = [fTorrents objectAtIndex: 0];
+        Torrent * torrent = fTorrents[0];
 
         [fFileController setTorrent: torrent];
 
 
 - (BOOL) canQuickLookFile: (FileListNode *) item
 {
-    Torrent * torrent = [fTorrents objectAtIndex: 0];
+    Torrent * torrent = fTorrents[0];
     return ([item isFolder] || [torrent fileProgress: item] >= 1.0) && [torrent fileLocation: item];
 }
 
index 01a7e197b73043c59dc599fa39d57f7a7207ce76..bb6aefa9713f8405119ff1d97fac05a8edb64dae 100644 (file)
     if ([fTorrents count] != 1)
         return;
 
-    Torrent * torrent = [fTorrents objectAtIndex: 0];
+    Torrent * torrent = fTorrents[0];
 
     NSString * location = [torrent dataLocation];
     [fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
 
 - (void) revealDataFile: (id) sender
 {
-    Torrent * torrent = [fTorrents objectAtIndex: 0];
+    Torrent * torrent = fTorrents[0];
     NSString * location = [torrent dataLocation];
     if (!location)
         return;
 {
     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],
index 224c5fbc74ee4ace31d9e0f0441f4863768ac6da..fcb6238339531c743bcaa779b809d87deb98b960 100644 (file)
     if (tableView == fWebSeedTable)
     {
         NSString * ident = [column identifier];
-        NSDictionary * webSeed = [fWebSeeds objectAtIndex: row];
+        NSDictionary * webSeed = fWebSeeds[row];
 
         if ([ident isEqualToString: @"DL From"])
         {
     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;
 
         if  ([ident isEqualToString: @"Progress"])
         {
-            NSDictionary * peer = [fPeers objectAtIndex: row];
+            NSDictionary * peer = fPeers[row];
             [(PeerProgressIndicatorCell *)cell setSeed: [[peer objectForKey: @"Seed"] boolValue]];
         }
     }
     {
         const BOOL multiple = [fTorrents count] > 1;
 
-        NSDictionary * peer = [fPeers objectAtIndex: row];
+        NSDictionary * peer = fPeers[row];
         NSMutableArray * components = [NSMutableArray arrayWithCapacity: multiple ? 6 : 5];
 
         if (multiple)
     else
     {
         if ([fTorrents count] > 1)
-            return [[fWebSeeds objectAtIndex: row] objectForKey: @"Name"];
+            return [fWebSeeds[row] objectForKey: @"Name"];
     }
 
     return nil;
     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"]))
index 0edabb04f23a3828b8cfe3e2032077b126af8fd9..1eff4ad7762f2cc93265ce3b5cd3915795727124 100644 (file)
         NSArray * oldTrackers = fTrackers;
 
         if ([fTorrents count] == 1)
-            fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
+            fTrackers = [[fTorrents[0] allTrackerStats] retain];
         else
         {
             fTrackers = [[NSMutableArray alloc] init];
         NSArray * tierAndTrackerBeingAdded = [fTrackers objectsAtIndexes: addedIndexes];
 
         [fTrackers release];
-        fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
+        fTrackers = [[fTorrents[0] allTrackerStats] retain];
         [fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
 
         [fTrackerTable setTrackers: fTrackers];
 
 - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (NSInteger) row
 {
-    id item = [fTrackers objectAtIndex: row];
+    id item = fTrackers[row];
 
     if ([item isKindOfClass: [NSDictionary class]])
     {
 
 - (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];
 
 - (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
 - (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"])
     }
     else
     {
-        [fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
+        [fTrackerTable setTorrent: fTorrents[0]];
 
         [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
         [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
     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])
index 835a87d20c852078c56524a3992da93b25d79fc4..b10dbf806361df6556e670a9ba711378f49869ea 100644 (file)
@@ -480,7 +480,7 @@ typedef enum
     }
     else
     {
-        Torrent * torrent = [fTorrents objectAtIndex: 0];
+        Torrent * torrent = fTorrents[0];
 
         [fImageView setImage: [torrent icon]];
 
index 4ebe3fcc1ecce0351d874a771d259381a7985519..8c1788d1f0e4a6d5b4b81a700dffa0f5ebd15be8 100644 (file)
 - (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"];
 #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]);
 - (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"];
 }
 
index 4a66aa92c66394bebec8d18c23454c26286bbbc8..16f7232455226ca3cb4ee964a0dccd7eabc5d69b 100644 (file)
     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];
 }
index aee6cd159079cad90e1761ffb4d38236ee7ea1be..2072df99ee53df2450c0ef415c3cdf1119273065 100644 (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];
         {
             [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];
     [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);
     [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);
 
             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];
 
 
 - (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
         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];
     }
 
index 2b55d98d454d10ae7c0881c87ae2622fb271aba3..b32a6236235f37fc468c90b24f8a2e1ce694d1e5 100644 (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
index 27025b95235af77a806d19dc2fe935d40d338a0e..248ff62c6a51e7566f559a3bde11d02365da0918 100644 (file)
     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"];
 }
index e4e8ce94290e5ddc81169ce59779d39cf6d3314c..69d9e8bb04aaa4d86ff22226481dab822578b5d5 100644 (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];
 
index b52440769aaa015955feb2ad351a58a77362d4dd..181dc01f1505e6f42c518c3108875cf6f4b4591e 100644 (file)
     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