NSDictionary init literals

This commit is contained in:
Dmitry Serov 2017-07-08 22:02:00 +07:00
parent 95ae0688eb
commit 22cabec67b
12 changed files with 46 additions and 43 deletions

View File

@ -140,8 +140,8 @@ typedef enum
static void altSpeedToggledCallback(tr_session * handle UNUSED, bool active, bool byUser, void * controller)
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active",
[[NSNumber alloc] initWithBool: byUser], @"ByUser", nil];
NSDictionary * dict = @{@"Active": @(active),
@"ByUser": @(byUser)};
[(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:)
withObject: dict waitUntilDone: NO];
}
@ -1199,8 +1199,8 @@ static void removeKeRangerRansomware()
//called on by applescript
- (void) open: (NSArray *) files
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: files, @"Filenames",
@(ADD_MANUAL), @"AddType", nil];
NSDictionary * dict = @{@"Filenames": files,
@"AddType": @(ADD_MANUAL)};
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dict waitUntilDone: NO];
}
@ -1221,8 +1221,8 @@ static void removeKeRangerRansomware()
for (NSURL * url in [panel URLs])
[filenames addObject: [url path]];
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: filenames, @"Filenames",
sender == fOpenIgnoreDownloadFolder ? @(ADD_SHOW_OPTIONS) : @(ADD_MANUAL), @"AddType", nil];
NSDictionary * dictionary = @{@"Filenames": filenames,
@"AddType": sender == fOpenIgnoreDownloadFolder ? @(ADD_SHOW_OPTIONS) : @(ADD_MANUAL)};
[self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
}
}];

View File

@ -565,8 +565,8 @@
case TR_MAKEMETA_OK:
if (fOpenWhenCreated)
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [fLocation path], @"File",
[[fPath URLByDeletingLastPathComponent] path], @"Path", nil];
NSDictionary * dict = @{@"File": [fLocation path],
@"Path": [[fPath URLByDeletingLastPathComponent] path]};
[[NSNotificationCenter defaultCenter] postNotificationName: @"OpenCreatedTorrentFile" object: self userInfo: dict];
}

View File

@ -42,15 +42,17 @@
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingMiddle];
fMainLineAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName,
bigFont, NSFontAttributeName, stringShadow, NSShadowAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
fMainLineAttributes = @{
NSForegroundColorAttributeName: [NSColor whiteColor],
NSFontAttributeName: bigFont,
NSShadowAttributeName: stringShadow,
NSParagraphStyleAttributeName: paragraphStyle};
fSubLineAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName,
smallFont, NSFontAttributeName, stringShadow, NSShadowAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
fSubLineAttributes = @{
NSForegroundColorAttributeName: [NSColor whiteColor],
NSFontAttributeName: smallFont,
NSShadowAttributeName: stringShadow,
NSParagraphStyleAttributeName: paragraphStyle};
[stringShadow release];
[paragraphStyle release];

View File

@ -52,14 +52,16 @@
[self setIgnoresMouseEvents: YES];
fFadeInAnimation = [[NSViewAnimation alloc] initWithViewAnimations: @[
[NSDictionary dictionaryWithObjectsAndKeys: self, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey, nil]]];
@{NSViewAnimationTargetKey: self,
NSViewAnimationEffectKey: NSViewAnimationFadeInEffect}
]];
[fFadeInAnimation setDuration: 0.15];
[fFadeInAnimation setAnimationBlockingMode: NSAnimationNonblockingThreaded];
fFadeOutAnimation = [[NSViewAnimation alloc] initWithViewAnimations: @[
[NSDictionary dictionaryWithObjectsAndKeys: self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil]]];
@{NSViewAnimationTargetKey: self,
NSViewAnimationEffectKey: NSViewAnimationFadeOutEffect}
]];
[fFadeOutAnimation setDuration: 0.5];
[fFadeOutAnimation setAnimationBlockingMode: NSAnimationNonblockingThreaded];

View File

@ -100,7 +100,7 @@
{
FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: col row: row];
NSDictionary * userInfo = [NSDictionary dictionaryWithObject: @(row) forKey: @"Row"];
NSDictionary * userInfo = @{@"Row": @(row)};
[cell addTrackingAreasForView: self inRect: [self frameOfCellAtColumn: col row: row] withUserInfo: userInfo
mouseLocation: mouseLocation];
}

View File

@ -269,7 +269,7 @@ GroupsController * fGroupsInstance = nil;
[fGroups removeObjectAtIndex: row];
[[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:
[NSDictionary dictionaryWithObject: @(index) forKey: @"Index"]];
@{@"Index": @(index)}];
if (index == [[NSUserDefaults standardUserDefaults] integerForKey: @"FilterGroup"])
[[NSUserDefaults standardUserDefaults] setInteger: -2 forKey: @"FilterGroup"];

View File

@ -296,7 +296,7 @@
NSAssert1([fTorrents count] == 1, @"Attempting to add tracker with %ld transfers selected", [fTorrents count]);
[fTrackers addObject: [NSDictionary dictionaryWithObject: @-1 forKey: @"Tier"]];
[fTrackers addObject: @{@"Tier": @-1}];
[fTrackers addObject: @""];
[fTrackerTable setTrackers: fTrackers];

View File

@ -211,14 +211,13 @@
NSString * file = [[@(currentMessage->file) lastPathComponent] stringByAppendingFormat: @":%d",
currentMessage->line];
NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys:
@(currentMessage->message), @"Message",
[NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
@(currentIndex++), @"Index", //more accurate when sorting by date
@(currentMessage->level), @"Level",
name, @"Name",
file, @"File", nil];
NSDictionary * message = @{
@"Message": @(currentMessage->message),
@"Date": [NSDate dateWithTimeIntervalSince1970: currentMessage->when],
@"Index": @(currentIndex++), //more accurate when sorting by date
@"Level": @(currentMessage->level),
@"Name": name,
@"File": file};
[fMessages addObject: message];
if (currentMessage->level <= maxLevel && [self shouldIncludeMessageForFilter: filterString message: message])
@ -407,7 +406,7 @@
{
//make the array sorted by date
NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"Index" ascending: YES];
NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
NSArray * descriptors = @[descriptor];
NSArray * sortedMessages = [fDisplayedMessages sortedArrayUsingDescriptors: descriptors];
[descriptors release];

View File

@ -53,8 +53,8 @@
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setAlignment: NSRightTextAlignment];
fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [NSFont systemFontOfSize: 11.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
fAttributes = @{NSFontAttributeName: [NSFont systemFontOfSize: 11.0],
NSParagraphStyleAttributeName: paragraphStyle};
[paragraphStyle release];
}

View File

@ -224,13 +224,13 @@ bool trashDataFile(const char * filename, tr_error ** error)
- (NSDictionary *) history
{
return [NSDictionary dictionaryWithObjectsAndKeys:
[self torrentLocation], @"InternalTorrentPath",
[self hashString], @"TorrentHash",
@([self isActive]), @"Active",
@([self waitingToStart]), @"WaitToStart",
@(fGroupValue), @"GroupValue",
@(fRemoveWhenFinishSeeding), @"RemoveWhenFinishSeeding", nil];
return @{
@"InternalTorrentPath": [self torrentLocation],
@"TorrentHash": [self hashString],
@"Active": @([self isActive]),
@"WaitToStart": @([self waitingToStart]),
@"GroupValue": @(fGroupValue),
@"RemoveWhenFinishSeeding": @(fRemoveWhenFinishSeeding)};
}
- (void) dealloc

View File

@ -238,7 +238,7 @@
if (![[self itemAtRow: row] isKindOfClass: [Torrent class]])
continue;
NSDictionary * userInfo = [NSDictionary dictionaryWithObject: @(row) forKey: @"Row"];
NSDictionary * userInfo = @{@"Row": @(row)};
TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: -1 row: row];
[cell addTrackingAreasForView: self inRect: [self rectOfRow: row] withUserInfo: userInfo mouseLocation: mouseLocation];
}

View File

@ -306,7 +306,7 @@ NSString * VDKQueueAccessRevocationNotification = @"VDKQueueAccessWasRevokedNoti
if (!_delegate || _alwaysPostNotifications)
{
NSDictionary *userInfoDict = [[NSDictionary alloc] initWithObjectsAndKeys:fpath, @"path", nil];
NSDictionary *userInfoDict = @{@"path": fpath};
[[[NSWorkspace sharedWorkspace] notificationCenter] postNotificationName:note object:self userInfo:userInfoDict];
[userInfoDict release];
}