[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)
if (result == NSFileHandlingPanelOKButton)
{
fLockDestination = YES;
- [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path] determinationType: TorrentDeterminationUserSpecified];
+ [self setDestinationPath: [[panel URLs][0] path] determinationType: TorrentDeterminationUserSpecified];
}
else
{
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:
//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);
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];
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]];
if (result == NSFileHandlingPanelOKButton)
{
for (Torrent * torrent in torrents)
- [torrent moveTorrentDataFileTo: [[[panel URLs] objectAtIndex: 0] path]];
+ [torrent moveTorrentDataFileTo: [[panel URLs][0] path]];
}
}];
}
return;
}
- Torrent * torrent = [torrents objectAtIndex: 0];
+ Torrent * torrent = torrents[0];
if (![torrent isMagnet] && [[NSFileManager defaultManager] fileExistsAtPath: [torrent torrentLocation]])
{
{
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)
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"),
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];
[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
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);
}];
- (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
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;
{
if (!fOverlayWindow)
fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
- [fOverlayWindow setFile: [[files objectAtIndex: 0] lastPathComponent]];
+ [fOverlayWindow setFile: [files[0] lastPathComponent]];
return NSDragOperationCopy;
}
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;
}
- (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
- (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
//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;
}
{
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)
- (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
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
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];
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;
}
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;
- (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];
- (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"];
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"];
- (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];
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"];
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)
{
- (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:
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];
}
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];
[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];
}
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],
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"]))
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])
}
else
{
- Torrent * torrent = [fTorrents objectAtIndex: 0];
+ Torrent * torrent = fTorrents[0];
[fImageView setImage: [torrent icon]];
- (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"];
}
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];
}
[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];
}
* 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];
//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:
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];
}
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
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"];
}
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];
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