Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use new literal syntax

  • Loading branch information...
commit c17060d99e3e0c1cc98c0340cb39355b14481d80 1 parent 6582f18
@psychs authored
Showing with 487 additions and 496 deletions.
  1. +34 −37 Classes/Controllers/AppController.m
  2. +10 −12 Classes/Controllers/GrowlController.m
  3. +7 −10 Classes/Controllers/MenuController.m
  4. +5 −5 Classes/Controllers/TwitterAvatarURLManager.m
  5. +17 −17 Classes/Dialogs/DCC/DCCController.m
  6. +12 −12 Classes/Dialogs/DCC/DCCFileTransferCell.m
  7. +1 −1  Classes/Dialogs/DCC/DCCSender.m
  8. +2 −2 Classes/Dialogs/IgnoreItemSheet.m
  9. +3 −3 Classes/Dialogs/InviteSheet.m
  10. +17 −17 Classes/Dialogs/ListDialog.m
  11. +25 −26 Classes/Dialogs/PasteSheet.m
  12. +4 −4 Classes/Dialogs/Preferences/PreferencesController.m
  13. +12 −12 Classes/Dialogs/ServerDialog.m
  14. +18 −18 Classes/Dialogs/WelcomeDialog.m
  15. +1 −1  Classes/Helpers/NSArrayHelper.m
  16. +21 −20 Classes/Helpers/NSColorHelper.m
  17. +11 −11 Classes/Helpers/NSDictionaryHelper.m
  18. +1 −1  Classes/Helpers/NSLocaleHelper.m
  19. +2 −2 Classes/Helpers/NSPasteboardHelper.m
  20. +1 −1  Classes/Helpers/NSStringHelper.m
  21. +1 −1  Classes/Helpers/URLOpener.m
  22. +12 −12 Classes/IRC/IRCChannel.m
  23. +9 −9 Classes/IRC/IRCChannelConfig.m
  24. +11 −11 Classes/IRC/IRCClient.m
  25. +20 −20 Classes/IRC/IRCClientConfig.m
  26. +1 −1  Classes/IRC/IRCConnection.m
  27. +1 −1  Classes/IRC/IRCISupportInfo.m
  28. +2 −2 Classes/IRC/IRCMessage.m
  29. +2 −2 Classes/IRC/IRCSendingMessage.m
  30. +16 −16 Classes/IRC/IRCWorld.m
  31. +3 −3 Classes/IRC/IRCWorldConfig.m
  32. +9 −9 Classes/IRC/IgnoreItem.m
  33. +46 −42 Classes/Library/AsyncSocket.m
  34. +7 −7 Classes/Library/GistClient.m
  35. +3 −3 Classes/Library/HostResolver.m
  36. +1 −1  Classes/Library/ImageSizeCheckClient.m
  37. +4 −4 Classes/Library/InputHistory.m
  38. +13 −13 Classes/Library/KeyEventHandler.m
  39. +3 −3 Classes/Library/YAML/SyckInput.m
  40. +10 −12 Classes/Library/YAML/YAMLCategories.m
  41. +9 −9 Classes/Preferences/OtherTheme.m
  42. +3 −3 Classes/Preferences/Preferences.m
  43. +2 −2 Classes/Preferences/ViewTheme.m
  44. +1 −1  Classes/Views/InputTextField.m
  45. +67 −70 Classes/Views/KeyRecorder/KeyRecorder.m
  46. +4 −4 Classes/Views/Log/ImageURLParser.m
  47. +11 −11 Classes/Views/Log/LogController.m
  48. +3 −3 Classes/Views/Log/LogPolicy.m
  49. +1 −1  Classes/Views/MemberList/MemberListView.m
  50. +8 −8 Classes/Views/MemberList/MemberListViewCell.m
View
71 Classes/Controllers/AppController.m
@@ -471,7 +471,7 @@ - (void)loadWindowState
int y = [dic intForKey:@"y"];
int w = [dic intForKey:@"w"];
int h = [dic intForKey:@"h"];
- id spellCheckingValue = [dic objectForKey:@"spell_checking"];
+ id spellCheckingValue = dic[@"spell_checking"];
[window setFrame:NSMakeRect(x, y, w, h) display:YES];
rootSplitter.position = [dic intForKey:@"root"];
@@ -629,18 +629,15 @@ - (void)completeNick:(BOOL)forward
CGFloat firstUserWeight = 0;
if (commandMode) {
- choices = [NSArray arrayWithObjects:
- @"action", @"away", @"ban", @"clear", @"close",
- @"ctcp", @"ctcpreply", @"cycle", @"dehalfop", @"deop",
- @"devoice", @"halfop", @"hop", @"ignore", @"invite",
- @"ison", @"join", @"kick", @"leave", @"list",
- @"me", @"mode", @"msg", @"nick", @"notice",
- @"op", @"part", @"pong", @"privmsg", @"query",
- @"quit", @"quote", @"raw", @"rejoin", @"timer",
- @"topic", @"umode", @"unban", @"unignore", @"voice",
- @"weights", @"who", @"whois", @"whowas",
- nil];
- lowerChoices = choices;
+ lowerChoices = @[@"action", @"away", @"ban", @"clear", @"close",
+ @"ctcp", @"ctcpreply", @"cycle", @"dehalfop", @"deop",
+ @"devoice", @"halfop", @"hop", @"ignore", @"invite",
+ @"ison", @"join", @"kick", @"leave", @"list",
+ @"me", @"mode", @"msg", @"nick", @"notice",
+ @"op", @"part", @"pong", @"privmsg", @"query",
+ @"quit", @"quote", @"raw", @"rejoin", @"timer",
+ @"topic", @"umode", @"unban", @"unignore", @"voice",
+ @"weights", @"who", @"whois", @"whowas"];
}
else {
NSMutableArray* users = [[channel.members mutableCopy] autorelease];
@@ -671,7 +668,7 @@ - (void)completeNick:(BOOL)forward
int i = 0;
for (NSString* s in lowerChoices) {
if ([s hasPrefix:lowerPre]) {
- [currentChoices addObject:[choices objectAtIndex:i]];
+ [currentChoices addObject:choices[i]];
[currentLowerChoices addObject:s];
}
++i;
@@ -683,7 +680,7 @@ - (void)completeNick:(BOOL)forward
if (!currentChoices.count) {
if (current.length) return;
if (!commandMode && !twitterMode && firstUserWeight > 0) {
- NSString* firstChoice = [choices objectAtIndex:0];
+ NSString* firstChoice = choices[0];
[currentChoices addObject:firstChoice];
[currentLowerChoices addObject:[firstChoice lowercaseString]];
}
@@ -710,10 +707,10 @@ - (void)completeNick:(BOOL)forward
--index;
}
}
- t = [currentChoices objectAtIndex:index];
+ t = currentChoices[index];
}
else {
- t = [currentChoices objectAtIndex:0];
+ t = currentChoices[0];
}
// add suffix
@@ -878,7 +875,7 @@ - (void)move:(MoveKind)dir target:(MoveKind)target
if (n == start) break;
- client = [world.clients objectAtIndex:n];
+ client = world.clients[n];
if (client) {
if (target == MOVE_ACTIVE) {
if (client.isLoggedIn) {
@@ -1095,7 +1092,7 @@ - (void)registerKeyHandlers
- (void)welcomeDialog:(WelcomeDialog*)sender onOK:(NSDictionary*)config
{
- NSString* host = [config objectForKey:@"host"];
+ NSString* host = config[@"host"];
NSString* name = host;
NSString* hostPattern = @"^[^\\s]+\\s+\\(([^()]+)\\)";
@@ -1105,29 +1102,29 @@ - (void)welcomeDialog:(WelcomeDialog*)sender onOK:(NSDictionary*)config
name = [host substringWithRange:[result rangeAtIndex:1]];
}
- NSString* nick = [config objectForKey:@"nick"];
+ NSString* nick = config[@"nick"];
NSString* user = [[nick lowercaseString] safeUsername];
NSString* realName = nick;
NSMutableArray* channels = [NSMutableArray array];
- for (NSString* s in [config objectForKey:@"channels"]) {
- [channels addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- s, @"name",
- [NSNumber numberWithBool:YES], @"auto_join",
- [NSNumber numberWithBool:YES], @"console",
- [NSNumber numberWithBool:YES], @"growl",
- @"+sn", @"mode",
- nil]];
+ for (NSString* s in config[@"channels"]) {
+ [channels addObject:@{
+ @"name": s,
+ @"auto_join": @YES,
+ @"console": @YES,
+ @"growl": @YES,
+ @"mode": @"+sn",
+ }];
}
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
- [dic setObject:host forKey:@"host"];
- [dic setObject:name forKey:@"name"];
- [dic setObject:nick forKey:@"nick"];
- [dic setObject:user forKey:@"username"];
- [dic setObject:realName forKey:@"realname"];
- [dic setObject:channels forKey:@"channels"];
- [dic setObject:[config objectForKey:@"autoConnect"] forKey:@"auto_connect"];
+ dic[@"host"] = host;
+ dic[@"name"] = name;
+ dic[@"nick"] = nick;
+ dic[@"username"] = user;
+ dic[@"realname"] = realName;
+ dic[@"channels"] = channels;
+ dic[@"auto_connect"] = config[@"autoConnect"];
if ([NSLocale prefersJapaneseLanguage]) {
NSString* net = [host lowercaseString];
@@ -1136,10 +1133,10 @@ - (void)welcomeDialog:(WelcomeDialog*)sender onOK:(NSDictionary*)config
|| [net contains:@"quakenet"]
|| [net contains:@"mozilla"]
|| [net contains:@"ustream"]) {
- [dic setObject:[NSNumber numberWithLong:NSUTF8StringEncoding] forKey:@"encoding"];
+ dic[@"encoding"] = [NSNumber numberWithLong:NSUTF8StringEncoding];
}
else {
- [dic setObject:[NSNumber numberWithLong:NSISO2022JPStringEncoding] forKey:@"encoding"];
+ dic[@"encoding"] = [NSNumber numberWithLong:NSISO2022JPStringEncoding];
}
}
View
22 Classes/Controllers/GrowlController.m
@@ -141,15 +141,13 @@ - (void)notify:(GrowlNotificationType)type title:(NSString*)title desc:(NSString
- (NSDictionary*)registrationDictionaryForGrowl
{
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
- NSArray* all = [NSArray arrayWithObjects:
- GROWL_MSG_LOGIN, GROWL_MSG_DISCONNECT, GROWL_MSG_HIGHLIGHT,
- GROWL_MSG_NEW_TALK, GROWL_MSG_CHANNEL_MSG, GROWL_MSG_CHANNEL_NOTICE,
- GROWL_MSG_TALK_MSG, GROWL_MSG_TALK_NOTICE, GROWL_MSG_KICKED,
- GROWL_MSG_INVITED, GROWL_MSG_FILE_RECEIVE_REQUEST, GROWL_MSG_FILE_RECEIVE_SUCCEEDED,
- GROWL_MSG_FILE_RECEIVE_FAILED, GROWL_MSG_FILE_SEND_SUCCEEDED, GROWL_NSG_FILE_SEND_FAILED,
- nil];
- [dic setObject:all forKey:GROWL_NOTIFICATIONS_ALL];
- [dic setObject:all forKey:GROWL_NOTIFICATIONS_DEFAULT];
+ NSArray* all = @[GROWL_MSG_LOGIN, GROWL_MSG_DISCONNECT, GROWL_MSG_HIGHLIGHT,
+ GROWL_MSG_NEW_TALK, GROWL_MSG_CHANNEL_MSG, GROWL_MSG_CHANNEL_NOTICE,
+ GROWL_MSG_TALK_MSG, GROWL_MSG_TALK_NOTICE, GROWL_MSG_KICKED,
+ GROWL_MSG_INVITED, GROWL_MSG_FILE_RECEIVE_REQUEST, GROWL_MSG_FILE_RECEIVE_SUCCEEDED,
+ GROWL_MSG_FILE_RECEIVE_FAILED, GROWL_MSG_FILE_SEND_SUCCEEDED, GROWL_NSG_FILE_SEND_FAILED];
+ dic[GROWL_NOTIFICATIONS_ALL] = all;
+ dic[GROWL_NOTIFICATIONS_DEFAULT] = all;
return dic;
}
@@ -177,8 +175,8 @@ - (void)growlNotificationWasClicked:(id)context
NSString* s = context;
NSArray* ary = [s componentsSeparatedByString:@" "];
if (ary.count >= 2) {
- int uid = [[ary objectAtIndex:0] intValue];
- int cid = [[ary objectAtIndex:1] intValue];
+ int uid = [ary[0] intValue];
+ int cid = [ary[1] intValue];
IRCClient* u = [owner findClientById:uid];
IRCChannel* c = [owner findChannelByClientId:uid channelId:cid];
@@ -190,7 +188,7 @@ - (void)growlNotificationWasClicked:(id)context
}
}
else if (ary.count == 1) {
- int uid = [[ary objectAtIndex:0] intValue];
+ int uid = [ary[0] intValue];
IRCClient* u = [owner findClientById:uid];
if (u) {
View
17 Classes/Controllers/MenuController.m
@@ -317,20 +317,20 @@ - (NSArray*)selectedMembers:(NSMenuItem*)sender
if ([self isNickMenu:sender]) {
IRCUser* m = [[IRCUser new] autorelease];
m.nick = pointedNick;
- return [NSArray arrayWithObject:m];
+ return @[m];
}
else {
- return [NSArray array];
+ return @[];
}
}
else {
if ([self isNickMenu:sender]) {
IRCUser* m = [c findMember:pointedNick];
if (m) {
- return [NSArray arrayWithObject:m];
+ return @[m];
}
else {
- return [NSArray array];
+ return @[];
}
}
else {
@@ -482,10 +482,7 @@ - (void)pasteSheetOnCancel:(PasteSheet*)sender
- (void)pasteSheetWillClose:(PasteSheet*)sender
{
NSSize size = pasteSheet.size;
- NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:size.width], @"w",
- [NSNumber numberWithInt:size.height], @"h",
- nil];
+ NSDictionary* dic = @{@"w": [NSNumber numberWithInt:size.width], @"h": [NSNumber numberWithInt:size.height]};
[Preferences saveWindowState:dic name:@"paste_sheet"];
if (!pasteSheet.isShortText) {
@@ -517,7 +514,7 @@ - (void)onPaste:(id)sender
multiLine = YES;
}
else if (lines.count == 2) {
- NSString* lastLine = [lines objectAtIndex:1];
+ NSString* lastLine = lines[1];
multiLine = lastLine.length > 0;
}
IRCChannel* c = world.selectedChannel;
@@ -579,7 +576,7 @@ - (void)onUseSelectionForFind:(id)sender
}
else if ([t respondsToSelector:@selector(writeSelectionToPasteboard:type:)]) {
NSPasteboard* pb = [NSPasteboard pasteboardWithName:NSFindPboard];
- [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+ [pb declareTypes:@[NSStringPboardType] owner:nil];
[t writeSelectionToPasteboard:pb type:NSStringPboardType];
}
}
View
10 Classes/Controllers/TwitterAvatarURLManager.m
@@ -38,7 +38,7 @@ - (void)dealloc
- (NSString*)imageURLForTwitterScreenName:(NSString*)screenName
{
- return [imageUrls objectForKey:screenName];
+ return imageUrls[screenName];
}
- (BOOL)fetchImageURLForTwitterScreenName:(NSString*)screenName
@@ -47,19 +47,19 @@ - (BOOL)fetchImageURLForTwitterScreenName:(NSString*)screenName
return NO;
}
- NSString* url = [imageUrls objectForKey:screenName];
+ NSString* url = imageUrls[screenName];
if (url) {
return NO;
}
- if ([connections objectForKey:screenName]) {
+ if (connections[screenName]) {
return NO;
}
TwitterImageURLClient *client = [[TwitterImageURLClient new] autorelease];
client.delegate = self;
client.screenName = screenName;
- [connections setObject:client forKey:screenName];
+ connections[screenName] = client;
[client getImageURL];
return YES;
@@ -76,7 +76,7 @@ - (void)twitterImageURLClient:(TwitterImageURLClient*)sender didGetImageURL:(NSS
NSString* screenName = sender.screenName;
if (screenName.length && imageUrl.length) {
- [imageUrls setObject:imageUrl forKey:screenName];
+ imageUrls[screenName] = imageUrl;
[[NSNotificationCenter defaultCenter] postNotificationName:TwitterAvatarURLManagerDidGetImageURLNotification object:screenName];
}
}
View
34 Classes/Dialogs/DCC/DCCController.m
@@ -157,7 +157,7 @@ - (void)addSenderWithUID:(int)uid nick:(NSString*)nick fileName:(NSString*)fileN
NSFileManager* fm = [NSFileManager defaultManager];
NSDictionary* attr = [fm attributesOfItemAtPath:fileName error:NULL];
if (!attr) return;
- NSNumber* sizeNum = [attr objectForKey:NSFileSize];
+ NSNumber* sizeNum = attr[NSFileSize];
long long size = [sizeNum longLongValue];
if (!size) return;
@@ -222,7 +222,7 @@ - (void)updateClearButton
BOOL enabled = NO;
for (int i=receivers.count-1; i>=0; --i) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
if (e.status == DCC_ERROR || e.status == DCC_COMPLETE || e.status == DCC_STOP) {
enabled = YES;
break;
@@ -231,7 +231,7 @@ - (void)updateClearButton
if (!enabled) {
for (int i=senders.count-1; i>=0; --i) {
- DCCSender* e = [senders objectAtIndex:i];
+ DCCSender* e = senders[i];
if (e.status == DCC_ERROR || e.status == DCC_COMPLETE || e.status == DCC_STOP) {
enabled = YES;
break;
@@ -278,7 +278,7 @@ - (void)saveWindowState
- (void)destroyReceiverAtIndex:(int)i
{
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
e.delegate = nil;
[e close];
@@ -292,7 +292,7 @@ - (void)destroyReceiverAtIndex:(int)i
- (void)destroySenderAtIndex:(int)i
{
- DCCSender* e = [senders objectAtIndex:i];
+ DCCSender* e = senders[i];
e.delegate = nil;
[e close];
@@ -317,7 +317,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item
NSMutableArray* sel = [NSMutableArray array];
NSIndexSet* indexes = [receiverTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- [sel addObject:[receivers objectAtIndex:i]];
+ [sel addObject:receivers[i]];
}
switch (tag) {
@@ -361,7 +361,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item
NSMutableArray* sel = [NSMutableArray array];
NSIndexSet* indexes = [senderTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- [sel addObject:[senders objectAtIndex:i]];
+ [sel addObject:senders[i]];
}
switch (tag) {
@@ -390,14 +390,14 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item
- (void)clear:(id)sender
{
for (int i=receivers.count-1; i>=0; --i) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
if (e.status == DCC_ERROR || e.status == DCC_COMPLETE || e.status == DCC_STOP) {
[self destroyReceiverAtIndex:i];
}
}
for (int i=senders.count-1; i>=0; --i) {
- DCCSender* e = [senders objectAtIndex:i];
+ DCCSender* e = senders[i];
if (e.status == DCC_ERROR || e.status == DCC_COMPLETE || e.status == DCC_STOP) {
[self destroySenderAtIndex:i];
}
@@ -411,7 +411,7 @@ - (void)startReceiver:(id)sender
{
NSIndexSet* indexes = [receiverTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
[e open];
}
@@ -423,7 +423,7 @@ - (void)stopReceiver:(id)sender
{
NSIndexSet* indexes = [receiverTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
[e close];
}
@@ -448,7 +448,7 @@ - (void)openReceiver:(id)sender
NSIndexSet* indexes = [receiverTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
[ws openFile:e.downloadFileName];
}
@@ -462,7 +462,7 @@ - (void)revealReceivedFileInFinder:(id)sender
NSIndexSet* indexes = [receiverTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCReceiver* e = [receivers objectAtIndex:i];
+ DCCReceiver* e = receivers[i];
[ws selectFile:e.downloadFileName inFileViewerRootedAtPath:nil];
}
@@ -474,7 +474,7 @@ - (void)startSender:(id)sender
{
NSIndexSet* indexes = [senderTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCSender* e = [senders objectAtIndex:i];
+ DCCSender* e = senders[i];
[e open];
}
@@ -486,7 +486,7 @@ - (void)stopSender:(id)sender
{
NSIndexSet* indexes = [senderTable selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- DCCSender* e = [senders objectAtIndex:i];
+ DCCSender* e = senders[i];
[e close];
}
@@ -665,7 +665,7 @@ - (void)tableView:(NSTableView *)sender willDisplayCell:(DCCFileTransferCell*)c
if (sender == senderTable) {
if (row < 0 || senders.count <= row) return;
- DCCSender* e = [senders objectAtIndex:row];
+ DCCSender* e = senders[row];
double speed = e.speed;
c.sendingItem = YES;
@@ -683,7 +683,7 @@ - (void)tableView:(NSTableView *)sender willDisplayCell:(DCCFileTransferCell*)c
else {
if (row < 0 || receivers.count <= row) return;
- DCCReceiver* e = [receivers objectAtIndex:row];
+ DCCReceiver* e = receivers[row];
double speed = e.speed;
c.sendingItem = NO;
View
24 Classes/Dialogs/DCC/DCCFileTransferCell.m
@@ -99,12 +99,12 @@ - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)view
fnameColor = [NSColor blackColor];
}
- NSDictionary* fnameAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
- fileNameStyle, NSParagraphStyleAttributeName,
- [NSFont systemFontOfSize:12], NSFontAttributeName,
- fnameColor, NSForegroundColorAttributeName,
- nil];
-
+ NSDictionary* fnameAttrs = @{
+ NSParagraphStyleAttributeName: fileNameStyle,
+ NSFontAttributeName: [NSFont systemFontOfSize:12],
+ NSForegroundColorAttributeName: fnameColor,
+ };
+
[fname drawInRect:fnameRect withAttributes:fnameAttrs];
if (progressBar) {
@@ -136,12 +136,12 @@ - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)view
statusColor = [NSColor grayColor];
}
- NSDictionary* statusAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
- statusStyle, NSParagraphStyleAttributeName,
- [NSFont systemFontOfSize:11], NSFontAttributeName,
- statusColor, NSForegroundColorAttributeName,
- nil];
-
+ NSDictionary* statusAttrs = @{
+ NSParagraphStyleAttributeName: statusStyle,
+ NSFontAttributeName: [NSFont systemFontOfSize:11],
+ NSForegroundColorAttributeName: statusColor,
+ };
+
NSMutableString* statusStr = [NSMutableString string];
if (sendingItem) {
View
2  Classes/Dialogs/DCC/DCCSender.m
@@ -65,7 +65,7 @@ - (void)setFullFileName:(NSString *)value
NSFileManager* fm = [NSFileManager defaultManager];
NSDictionary* attr = [fm attributesOfItemAtPath:fullFileName error:NULL];
if (attr) {
- NSNumber* sizeNum = [attr objectForKey:NSFileSize];
+ NSNumber* sizeNum = attr[NSFileSize];
size = [sizeNum longLongValue];
}
else {
View
4 Classes/Dialogs/IgnoreItemSheet.m
@@ -175,12 +175,12 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)sender
- (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
- return [channels objectAtIndex:row];
+ return channels[row];
}
- (void)tableView:(NSTableView *)sender setObjectValue:(id)obj forTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
- [channels replaceObjectAtIndex:row withObject:obj];
+ channels[row] = obj;
}
- (void)tableViewSelectionDidChange:(NSNotification *)note
View
6 Classes/Dialogs/InviteSheet.m
@@ -32,11 +32,11 @@ - (void)startWithChannels:(NSArray*)channels
{
NSString* target;
if (nicks.count == 1) {
- target = [nicks objectAtIndex:0];
+ target = nicks[0];
}
else if (nicks.count == 2) {
- NSString* first = [nicks objectAtIndex:0];
- NSString* second = [nicks objectAtIndex:1];
+ NSString* first = nicks[0];
+ NSString* second = nicks[1];
target = [NSString stringWithFormat:@"%@ and %@", first, second];
}
else {
View
34 Classes/Dialogs/ListDialog.m
@@ -52,8 +52,8 @@ - (void)show
if (![self.window isVisible]) {
NSDictionary* dic = [Preferences loadWindowStateWithName:@"channel_list_window"];
if (dic) {
- NSDictionary* win = [dic objectForKey:@"window"];
- NSArray* cols = [dic objectForKey:@"tablecols"];
+ NSDictionary* win = dic[@"window"];
+ NSArray* cols = dic[@"tablecols"];
double x = [win doubleForKey:@"x"];
double y = [win doubleForKey:@"y"];
@@ -91,7 +91,7 @@ - (void)clear
- (void)addChannel:(NSString*)channel count:(int)count topic:(NSString*)topic
{
- NSArray* item = [NSArray arrayWithObjects:channel, [NSNumber numberWithInt:count], topic, nil];
+ NSArray* item = @[channel, [NSNumber numberWithInt:count], topic];
NSString* filter = [filterText stringValue];
if (filter.length) {
@@ -120,7 +120,7 @@ static NSInteger compareItems(NSArray* self, NSArray* other, void* context)
int key = dialog.sortKey;
NSComparisonResult order = dialog.sortOrder;
- NSString* mine = [self objectAtIndex:key];
+ NSString* mine = self[key];
NSString* others = [other objectAtIndex:key];
NSComparisonResult result;
@@ -152,7 +152,7 @@ - (void)sortedInsert:(NSArray*)item inArray:(NSMutableArray*)ary
while (right - left > THRESHOLD) {
int pivot = (left + right) / 2;
- if (compareItems([ary objectAtIndex:pivot], item, self) == NSOrderedDescending) {
+ if (compareItems(ary[pivot], item, self) == NSOrderedDescending) {
right = pivot;
}
else {
@@ -161,7 +161,7 @@ - (void)sortedInsert:(NSArray*)item inArray:(NSMutableArray*)ary
}
for (int i=left; i<right; ++i) {
- if (compareItems([ary objectAtIndex:i], item, self) == NSOrderedDescending) {
+ if (compareItems(ary[i], item, self) == NSOrderedDescending) {
[ary insertObject:item atIndex:i];
return;
}
@@ -195,9 +195,9 @@ - (void)onJoin:(id)sender
NSIndexSet* indexes = [table selectedRowIndexes];
for (NSUInteger i=[indexes firstIndex]; i!=NSNotFound; i=[indexes indexGreaterThanIndex:i]) {
- NSArray* item = [ary objectAtIndex:i];
+ NSArray* item = ary[i];
if ([delegate respondsToSelector:@selector(listDialogOnJoin:channel:)]) {
- [delegate listDialogOnJoin:self channel:[item objectAtIndex:0]];
+ [delegate listDialogOnJoin:self channel:item[0]];
}
}
}
@@ -211,8 +211,8 @@ - (void)onSearchFieldChange:(id)sender
if (filter.length) {
NSMutableArray* ary = [NSMutableArray new];
for (NSArray* item in list) {
- NSString* channel = [item objectAtIndex:0];
- NSString* topic = [item objectAtIndex:2];
+ NSString* channel = item[0];
+ NSString* topic = item[2];
if ([channel rangeOfString:filter options:NSCaseInsensitiveSearch].location != NSNotFound
|| [topic rangeOfString:filter options:NSCaseInsensitiveSearch].location != NSNotFound) {
[ary addObject:item];
@@ -229,8 +229,8 @@ - (BOOL)loadWindowState
NSDictionary* dic = [Preferences loadWindowStateWithName:@"channel_list_window"];
if (!dic) return NO;
- NSDictionary* win = [dic objectForKey:@"window"];
- NSArray* cols = [dic objectForKey:@"tablecols"];
+ NSDictionary* win = dic[@"window"];
+ NSArray* cols = dic[@"tablecols"];
double x = [win doubleForKey:@"x"];
double y = [win doubleForKey:@"y"];
@@ -261,7 +261,7 @@ - (void)saveWindowState
[cols addObject:[NSNumber numberWithDouble:col.width]];
}
- NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:win, @"window", cols, @"tablecols", nil];
+ NSDictionary* dic = @{@"window": win, @"tablecols": cols};
[Preferences saveWindowState:dic name:@"channel_list_window"];
}
@@ -279,17 +279,17 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)sender
- (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
NSArray* ary = filteredList ?: list;
- NSArray* item = [ary objectAtIndex:row];
+ NSArray* item = ary[row];
NSString* col = [column identifier];
if ([col isEqualToString:@"chname"]) {
- return [item objectAtIndex:0];
+ return item[0];
}
else if ([col isEqualToString:@"count"]) {
- return [item objectAtIndex:1];
+ return item[1];
}
else {
- return [item objectAtIndex:2];
+ return item[2];
}
}
View
51 Classes/Dialogs/PasteSheet.m
@@ -35,33 +35,32 @@ - (id)init
[NSBundle loadNibNamed:@"PasteSheet" owner:self];
if (!SYNTAXES) {
- SYNTAXES = [[NSArray arrayWithObjects:
- @"privmsg", @"notice", @"c", @"css", @"diff", @"html",
- @"java", @"javascript", @"php", @"plain text", @"python",
- @"ruby", @"sql", @"shell script", @"perl", @"haskell",
- @"scheme", @"objective-c",
- nil] retain];
+ SYNTAXES = [@[@"privmsg", @"notice", @"c", @"css", @"diff", @"html",
+ @"java", @"javascript", @"php", @"plain text", @"python",
+ @"ruby", @"sql", @"shell script", @"perl", @"haskell",
+ @"scheme", @"objective-c"] retain];
}
if (!SYNTAX_EXT_MAP) {
- SYNTAX_EXT_MAP = [[NSDictionary dictionaryWithObjectsAndKeys:
- @".c", @"c",
- @".css", @"css",
- @".diff", @"diff",
- @".hs", @"haskell",
- @".html", @"html",
- @".java", @"java",
- @".js", @"javascript",
- @".m", @"objective-c",
- @".pl", @"perl",
- @".aw", @"php",
- @".txt", @"plain_text",
- @".py", @"python",
- @".rb", @"ruby",
- @".scm", @"scheme",
- @".sh", @"shell script",
- @".sql", @"sql",
- nil, nil] retain];
+ SYNTAX_EXT_MAP = @{
+ @"c": @".c",
+ @"css": @".css",
+ @"diff": @".diff",
+ @"haskell": @".hs",
+ @"html": @".html",
+ @"java": @".java",
+ @"javascript": @".js",
+ @"objective-c": @".m",
+ @"perl": @".pl",
+ @"php": @".aw",
+ @"plain_text": @".txt",
+ @"python": @".py",
+ @"ruby": @".rb",
+ @"scheme": @".scm",
+ @"shell_script": @".sh",
+ @"sql": @".sql",
+ };
+ [SYNTAX_EXT_MAP retain];
}
}
return self;
@@ -110,7 +109,7 @@ - (void)pasteOnline:(id)sender
}
NSString* s = bodyText.string;
- NSString* fileType = [SYNTAX_EXT_MAP objectForKey:[self syntaxFromTag:syntaxPopup.selectedTag]];
+ NSString* fileType = SYNTAX_EXT_MAP[[self syntaxFromTag:syntaxPopup.selectedTag]];
if (!fileType) {
fileType = @".txt";
}
@@ -182,7 +181,7 @@ - (int)tagFromSyntax:(NSString*)s
- (NSString*)syntaxFromTag:(int)tag
{
if (0 <= tag && tag < SYNTAXES.count) {
- return [SYNTAXES objectAtIndex:tag];
+ return SYNTAXES[tag];
}
return nil;
}
View
8 Classes/Dialogs/Preferences/PreferencesController.m
@@ -215,7 +215,7 @@ - (NSArray*)availableSounds
{
static NSArray* ary;
if (!ary) {
- ary = [[NSArray arrayWithObjects:@"-", @"Beep", @"Basso", @"Blow", @"Bottle", @"Frog", @"Funk", @"Glass", @"Hero", @"Morse", @"Ping", @"Pop", @"Purr", @"Sosumi", @"Submarine", @"Tink", nil] retain];
+ ary = [@[@"-", @"Beep", @"Basso", @"Blow", @"Bottle", @"Frog", @"Funk", @"Glass", @"Hero", @"Morse", @"Ping", @"Pop", @"Purr", @"Sosumi", @"Submarine", @"Tink"] retain];
}
return ary;
}
@@ -354,7 +354,7 @@ - (void)updateTheme
[[themeButton itemAtIndex:0] setTag:0];
NSFileManager* fm = [NSFileManager defaultManager];
- NSArray* ary = [NSArray arrayWithObjects:[ViewTheme resourceBasePath], [ViewTheme userBasePath], nil];
+ NSArray* ary = @[[ViewTheme resourceBasePath], [ViewTheme userBasePath]];
int tag = 0;
for (NSString* path in ary) {
@@ -396,8 +396,8 @@ - (void)updateTheme
return;
}
- NSString* kind = [kindAndName objectAtIndex:0];
- NSString* name = [kindAndName objectAtIndex:1];
+ NSString* kind = kindAndName[0];
+ NSString* name = kindAndName[1];
int targetTag = 0;
if (![kind isEqualToString:@"resource"]) {
View
24 Classes/Dialogs/ServerDialog.m
@@ -11,7 +11,7 @@
#define IGNORE_TAB_INDEX 3
#define TABLE_ROW_TYPE @"row"
-#define TABLE_ROW_TYPES [NSArray arrayWithObject:TABLE_ROW_TYPE]
+#define TABLE_ROW_TYPES @[TABLE_ROW_TYPE]
@interface ServerDialog (Private)
@@ -234,7 +234,7 @@ - (void)ok:(id)sender
// remove invalid ignores
NSMutableArray* ignores = config.ignores;
for (int i=ignores.count-1; i>=0; --i) {
- IgnoreItem* g = [ignores objectAtIndex:i];
+ IgnoreItem* g = ignores[i];
if (!g.isValid) {
[ignores removeObjectAtIndex:i];
}
@@ -290,7 +290,7 @@ - (void)addChannel:(id)sender
conf = [[IRCChannelConfig new] autorelease];
}
else {
- IRCChannelConfig* c = [config.channels objectAtIndex:sel];
+ IRCChannelConfig* c = config.channels[sel];
conf = [[c mutableCopy] autorelease];
conf.name = @"";
}
@@ -309,7 +309,7 @@ - (void)editChannel:(id)sender
{
NSInteger sel = [channelTable selectedRow];
if (sel < 0) return;
- IRCChannelConfig* c = [[[config.channels objectAtIndex:sel] mutableCopy] autorelease];
+ IRCChannelConfig* c = [[config.channels[sel] mutableCopy] autorelease];
[channelSheet release];
channelSheet = [ChannelDialog new];
@@ -340,7 +340,7 @@ - (void)channelDialogOnOK:(ChannelDialog*)sender
[config.channels addObject:conf];
}
else {
- [config.channels replaceObjectAtIndex:n withObject:conf];
+ config.channels[n] = conf;
}
[self reloadChannelTable];
@@ -395,7 +395,7 @@ - (void)editIgnore:(id)sender
ignoreSheet = [IgnoreItemSheet new];
ignoreSheet.delegate = self;
ignoreSheet.window = self.window;
- ignoreSheet.ignore = [config.ignores objectAtIndex:sel];
+ ignoreSheet.ignore = config.ignores[sel];
[ignoreSheet start];
}
@@ -450,7 +450,7 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)sender
- (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
if (sender == channelTable) {
- IRCChannelConfig* c = [config.channels objectAtIndex:row];
+ IRCChannelConfig* c = config.channels[row];
NSString* columnId = [column identifier];
if ([columnId isEqualToString:@"name"]) {
@@ -464,7 +464,7 @@ - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *
}
}
else {
- IgnoreItem* g = [config.ignores objectAtIndex:row];
+ IgnoreItem* g = config.ignores[row];
NSString* columnId = [column identifier];
if ([columnId isEqualToString:@"nick"]) {
@@ -481,7 +481,7 @@ - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *
- (void)tableView:(NSTableView *)sender setObjectValue:(id)obj forTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
if (sender == channelTable) {
- IRCChannelConfig* c = [config.channels objectAtIndex:row];
+ IRCChannelConfig* c = config.channels[row];
NSString* columnId = [column identifier];
if ([columnId isEqualToString:@"join"]) {
@@ -518,7 +518,7 @@ - (void)tableViewDoubleClicked:(id)sender
- (BOOL)tableView:(NSTableView *)sender writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard *)pboard
{
if (sender == channelTable) {
- NSArray* ary = [NSArray arrayWithObject:[NSNumber numberWithInt:[rows firstIndex]]];
+ NSArray* ary = @[[NSNumber numberWithInt:[rows firstIndex]]];
[pboard declareTypes:TABLE_ROW_TYPES owner:self];
[pboard setPropertyList:ary forType:TABLE_ROW_TYPE];
}
@@ -550,10 +550,10 @@ - (BOOL)tableView:(NSTableView *)sender acceptDrop:(id < NSDraggingInfo >)info r
NSPasteboard* pboard = [info draggingPasteboard];
if (op == NSTableViewDropAbove && [pboard availableTypeFromArray:TABLE_ROW_TYPES]) {
NSArray* selectedRows = [pboard propertyListForType:TABLE_ROW_TYPE];
- int sel = [[selectedRows objectAtIndex:0] intValue];
+ int sel = [selectedRows[0] intValue];
NSMutableArray* ary = config.channels;
- IRCChannelConfig* target = [ary objectAtIndex:sel];
+ IRCChannelConfig* target = ary[sel];
[[target retain] autorelease];
NSMutableArray* low = [[[ary subarrayWithRange:NSMakeRange(0, row)] mutableCopy] autorelease];
View
36 Classes/Dialogs/WelcomeDialog.m
@@ -69,19 +69,19 @@ - (void)close
- (void)onOK:(id)sender
{
[self.window endEditingFor:nil];
-
+
/*
- NSText* fieldEditor = [self.window fieldEditor:NO forObject:channelTable];
- if (fieldEditor) {
- [[channelTable cell] endEditing:fieldEditor];
- NSInteger n = [channelTable editedRow];
- if (n != NSNotFound) {
- NSString* s = [[[fieldEditor string] copy] autorelease];
- if (n < channels.count) {
- [channels replaceObjectAtIndex:n withObject:s];
- }
- }
- }
+ NSText* fieldEditor = [self.window fieldEditor:NO forObject:channelTable];
+ if (fieldEditor) {
+ [[channelTable cell] endEditing:fieldEditor];
+ NSInteger n = [channelTable editedRow];
+ if (n != NSNotFound) {
+ NSString* s = [[[fieldEditor string] copy] autorelease];
+ if (n < channels.count) {
+ channels[n] = s;
+ }
+ }
+ }
*/
NSMutableSet* set = [NSMutableSet set];
@@ -101,10 +101,10 @@ - (void)onOK:(id)sender
}
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
- [dic setObject:nickText.stringValue forKey:@"nick"];
- [dic setObject:hostCombo.stringValue forKey:@"host"];
- [dic setObject:chans forKey:@"channels"];
- [dic setObject:[NSNumber numberWithBool:autoConnectCheck.state] forKey:@"autoConnect"];
+ dic[@"nick"] = nickText.stringValue;
+ dic[@"host"] = hostCombo.stringValue;
+ dic[@"channels"] = chans;
+ dic[@"autoConnect"] = [NSNumber numberWithBool:autoConnectCheck.state];
if ([delegate respondsToSelector:@selector(welcomeDialog:onOK:)]) {
[delegate welcomeDialog:self onOK:dic];
@@ -167,7 +167,7 @@ - (void)textDidEndEditing:(NSNotification*)note
NSInteger n = [channelTable editedRow];
if (n >= 0) {
NSString* s = [[[[[note object] textStorage] string] copy] autorelease];
- [channels replaceObjectAtIndex:n withObject:s];
+ channels[n] = s;
[channelTable reloadData];
[channelTable selectItemAtIndex:n];
[self tableViewSelectionIsChanging:nil];
@@ -181,7 +181,7 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)sender
- (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
- return [channels objectAtIndex:row];
+ return channels[row];
}
- (void)tableViewSelectionIsChanging:(NSNotification *)note
View
2  Classes/Helpers/NSArrayHelper.m
@@ -9,7 +9,7 @@ @implementation NSArray (NSArrayHelper)
- (id)safeObjectAtIndex:(int)n
{
if (0 <= n && n < self.count) {
- return [self objectAtIndex:n];
+ return self[n];
}
return nil;
}
View
41 Classes/Helpers/NSColorHelper.m
@@ -60,28 +60,29 @@ + (NSColor*)fromCSS:(NSString*)s
static NSDictionary* nameMap = nil;
if (!nameMap) {
- nameMap = [[NSDictionary dictionaryWithObjectsAndKeys:
- DEVICE_RGB(0, 0, 0), @"black",
- DEVICE_RGB(0xC0, 0xC0, 0xC0), @"silver",
- DEVICE_RGB(0x80, 0x80, 0x80), @"gray",
- DEVICE_RGB(0xFF, 0xFF, 0xFF), @"white",
- DEVICE_RGB(0x80, 0, 0), @"maroon",
- DEVICE_RGB(0xFF, 0, 0), @"red",
- DEVICE_RGB(0x80, 0, 0x80), @"purple",
- DEVICE_RGB(0xFF, 0, 0xFF), @"fuchsia",
- DEVICE_RGB(0, 0x80, 0), @"green",
- DEVICE_RGB(0, 0xFF, 0), @"lime",
- DEVICE_RGB(0x80, 0x80, 0), @"olive",
- DEVICE_RGB(0xFF, 0xFF, 0), @"yellow",
- DEVICE_RGB(0, 0, 0x80), @"navy",
- DEVICE_RGB(0, 0, 0xFF), @"blue",
- DEVICE_RGB(0, 0x80, 0x80), @"teal",
- DEVICE_RGB(0, 0xFF, 0xFF), @"aqua",
- DEVICE_RGBA(0, 0, 0, 0), @"transparent",
- nil] retain];
+ nameMap = @{
+ @"black": DEVICE_RGB(0, 0, 0),
+ @"silver": DEVICE_RGB(0xC0, 0xC0, 0xC0),
+ @"gray": DEVICE_RGB(0x80, 0x80, 0x80),
+ @"white": DEVICE_RGB(0xFF, 0xFF, 0xFF),
+ @"maroon": DEVICE_RGB(0x80, 0, 0),
+ @"red": DEVICE_RGB(0xFF, 0, 0),
+ @"purple": DEVICE_RGB(0x80, 0, 0x80),
+ @"fuchsia": DEVICE_RGB(0xFF, 0, 0xFF),
+ @"green": DEVICE_RGB(0, 0x80, 0),
+ @"lime": DEVICE_RGB(0, 0xFF, 0),
+ @"olive": DEVICE_RGB(0x80, 0x80, 0),
+ @"yellow": DEVICE_RGB(0xFF, 0xFF, 0),
+ @"navy": DEVICE_RGB(0, 0, 0x80),
+ @"blue": DEVICE_RGB(0, 0, 0xFF),
+ @"teal": DEVICE_RGB(0, 0x80, 0x80),
+ @"aqua": DEVICE_RGB(0, 0xFF, 0xFF),
+ @"transparent": DEVICE_RGBA(0, 0, 0, 0),
+ };
+ [nameMap retain];
}
- return [nameMap objectForKey:[s lowercaseString]];
+ return nameMap[[s lowercaseString]];
}
@end
View
22 Classes/Helpers/NSDictionaryHelper.m
@@ -8,7 +8,7 @@ @implementation NSDictionary (NSDictionaryHelper)
- (BOOL)boolForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj respondsToSelector:@selector(boolValue)]) {
return [obj boolValue];
}
@@ -17,7 +17,7 @@ - (BOOL)boolForKey:(NSString*)key
- (int)intForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj respondsToSelector:@selector(intValue)]) {
return [obj intValue];
}
@@ -26,7 +26,7 @@ - (int)intForKey:(NSString*)key
- (long long)longLongForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj respondsToSelector:@selector(longLongValue)]) {
return [obj longLongValue];
}
@@ -35,7 +35,7 @@ - (long long)longLongForKey:(NSString*)key
- (double)doubleForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj respondsToSelector:@selector(doubleValue)]) {
return [obj doubleValue];
}
@@ -44,7 +44,7 @@ - (double)doubleForKey:(NSString*)key
- (NSString*)stringForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj isKindOfClass:[NSString class]]) {
return obj;
}
@@ -53,7 +53,7 @@ - (NSString*)stringForKey:(NSString*)key
- (NSDictionary*)dictionaryForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj isKindOfClass:[NSDictionary class]]) {
return obj;
}
@@ -62,7 +62,7 @@ - (NSDictionary*)dictionaryForKey:(NSString*)key
- (NSArray*)arrayForKey:(NSString*)key
{
- id obj = [self objectForKey:key];
+ id obj = self[key];
if ([obj isKindOfClass:[NSArray class]]) {
return obj;
}
@@ -76,22 +76,22 @@ @implementation NSMutableDictionary (NSMutableDictionaryHelper)
- (void)setBool:(BOOL)value forKey:(NSString*)key
{
- [self setObject:[NSNumber numberWithBool:value] forKey:key];
+ self[key] = [NSNumber numberWithBool:value];
}
- (void)setInt:(int)value forKey:(NSString*)key
{
- [self setObject:[NSNumber numberWithInt:value] forKey:key];
+ self[key] = [NSNumber numberWithInt:value];
}
- (void)setLongLong:(long long)value forKey:(NSString*)key
{
- [self setObject:[NSNumber numberWithLongLong:value] forKey:key];
+ self[key] = [NSNumber numberWithLongLong:value];
}
- (void)setDouble:(double)value forKey:(NSString*)key
{
- [self setObject:[NSNumber numberWithDouble:value] forKey:key];
+ self[key] = [NSNumber numberWithDouble:value];
}
@end
View
2  Classes/Helpers/NSLocaleHelper.m
@@ -10,7 +10,7 @@ + (BOOL)prefersJapaneseLanguage
{
NSArray* langs = [self preferredLanguages];
if (langs.count) {
- NSString* primary = [langs objectAtIndex:0];
+ NSString* primary = langs[0];
if ([primary isEqualToString:@"ja"]) {
return YES;
}
View
4 Classes/Helpers/NSPasteboardHelper.m
@@ -8,7 +8,7 @@ @implementation NSPasteboard (NSPasteboardHelper)
- (BOOL)hasStringContent
{
- return [self availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil;
+ return [self availableTypeFromArray:@[NSStringPboardType]] != nil;
}
- (NSString*)stringContent
@@ -18,7 +18,7 @@ - (NSString*)stringContent
- (void)setStringContent:(NSString*)s
{
- [self declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+ [self declareTypes:@[NSStringPboardType] owner:nil];
[self setString:s forType:NSStringPboardType];
}
View
2  Classes/Helpers/NSStringHelper.m
@@ -93,7 +93,7 @@ - (NSArray*)splitIntoLines
int len = self.length;
const UniChar* buf = [self getCharactersBuffer];
if (!buf) {
- return [NSArray array];
+ return @[];
}
NSMutableArray* lines = [NSMutableArray array];
View
2  Classes/Helpers/URLOpener.m
@@ -12,7 +12,7 @@ + (void)open:(NSURL*)url
NSWorkspace* ws = [NSWorkspace sharedWorkspace];
if ([Preferences openBrowserInBackground]) {
- [ws openURLs:[NSArray arrayWithObject:url] withAppBundleIdentifier:nil options:NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor:nil launchIdentifiers:nil];
+ [ws openURLs:@[url] withAppBundleIdentifier:nil options:NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor:nil launchIdentifiers:nil];
}
else {
[ws openURL:url];
View
24 Classes/IRC/IRCChannel.m
@@ -220,7 +220,7 @@ - (void)sortedInsert:(IRCUser*)item
while (right - left > LINEAR_SEARCH_THRESHOLD) {
int i = (left + right) / 2;
- IRCUser* t = [members objectAtIndex:i];
+ IRCUser* t = members[i];
if ([t compare:item] == NSOrderedAscending) {
left = i + 1;
}
@@ -230,7 +230,7 @@ - (void)sortedInsert:(IRCUser*)item
}
for (int i=left; i<right; ++i) {
- IRCUser* t = [members objectAtIndex:i];
+ IRCUser* t = members[i];
if ([t compare:item] == NSOrderedDescending) {
[members insertObject:item atIndex:i];
return;
@@ -249,7 +249,7 @@ - (void)addMember:(IRCUser*)user reload:(BOOL)reload
{
int n = [self indexOfMember:user.nick];
if (n >= 0) {
- [[[members objectAtIndex:n] retain] autorelease];
+ [[members[n] retain] autorelease];
[members removeObjectAtIndex:n];
}
@@ -267,7 +267,7 @@ - (void)removeMember:(NSString*)nick reload:(BOOL)reload
{
int n = [self indexOfMember:nick];
if (n >= 0) {
- [[[members objectAtIndex:n] retain] autorelease];
+ [[members[n] retain] autorelease];
[members removeObjectAtIndex:n];
}
@@ -281,7 +281,7 @@ - (void)renameMember:(NSString*)fromNick to:(NSString*)toNick
int n = [self indexOfMember:fromNick];
if (n < 0) return;
- IRCUser* m = [members objectAtIndex:n];
+ IRCUser* m = members[n];
[[m retain] autorelease];
if (![fromNick isEqualNoCase:toNick]) {
[self removeMember:toNick reload:NO];
@@ -289,7 +289,7 @@ - (void)renameMember:(NSString*)fromNick to:(NSString*)toNick
m.nick = toNick;
- [[[members objectAtIndex:n] retain] autorelease];
+ [[members[n] retain] autorelease];
[members removeObjectAtIndex:n];
[self sortedInsert:m];
@@ -304,7 +304,7 @@ - (void)updateOrAddMember:(IRCUser*)user
{
int n = [self indexOfMember:user.nick];
if (n >= 0) {
- [[[members objectAtIndex:n] retain] autorelease];
+ [[members[n] retain] autorelease];
[members removeObjectAtIndex:n];
}
@@ -316,7 +316,7 @@ - (void)changeMember:(NSString*)nick mode:(char)modeChar value:(BOOL)value
int n = [self indexOfMember:nick];
if (n < 0) return;
- IRCUser* m = [members objectAtIndex:n];
+ IRCUser* m = members[n];
switch (modeChar) {
case 'q': m.q = value; break;
@@ -326,7 +326,7 @@ - (void)changeMember:(NSString*)nick mode:(char)modeChar value:(BOOL)value
case 'v': m.v = value; break;
}
- [[[members objectAtIndex:n] retain] autorelease];
+ [[members[n] retain] autorelease];
[members removeObjectAtIndex:n];
[self sortedInsert:m];
@@ -356,14 +356,14 @@ - (int)indexOfMember:(NSString*)nick
- (IRCUser*)memberAtIndex:(int)index
{
- return [members objectAtIndex:index];
+ return members[index];
}
- (IRCUser*)findMember:(NSString*)nick
{
int n = [self indexOfMember:nick];
if (n < 0) return nil;
- return [members objectAtIndex:n];
+ return members[n];
}
- (int)numberOfMembers
@@ -428,7 +428,7 @@ - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *
- (void)tableView:(NSTableView *)sender willDisplayCell:(MemberListViewCell*)cell forTableColumn:(NSTableColumn *)column row:(NSInteger)row
{
- cell.member = [members objectAtIndex:row];
+ cell.member = members[row];
}
@end
View
18 Classes/IRC/IRCChannelConfig.m
@@ -80,17 +80,17 @@ - (NSMutableDictionary*)dictionaryValue
[dic setInt:type forKey:@"type"];
- if (name) [dic setObject:name forKey:@"name"];
- if (password) [dic setObject:password forKey:@"password"];
-
- [dic setBool:autoJoin forKey:@"auto_join"];
- [dic setBool:logToConsole forKey:@"console"];
- [dic setBool:growl forKey:@"growl"];
+ if (name) dic[@"name"] = name;
+ if (password) dic[@"password"] = password;
+
+ dic[@"auto_join"] = [NSNumber numberWithBool:autoJoin];
+ dic[@"console"] = [NSNumber numberWithBool:logToConsole];
+ dic[@"growl"] = [NSNumber numberWithBool:growl];
- if (mode) [dic setObject:mode forKey:@"mode"];
- if (topic) [dic setObject:topic forKey:@"topic"];
+ if (mode) dic[@"mode"] = mode;
+ if (topic) dic[@"topic"] = topic;
- if (autoOp) [dic setObject:autoOp forKey:@"autoop"];
+ if (autoOp) dic[@"autoop"] = autoOp;
return dic;
}
View
22 Classes/IRC/IRCClient.m
@@ -288,8 +288,8 @@ - (NSMutableDictionary*)dictionaryValue
[ary addObject:[c dictionaryValue]];
}
}
-
- [dic setObject:ary forKey:@"channels"];
+
+ dic[@"channels"] = ary;
return dic;
}
@@ -1315,7 +1315,7 @@ - (BOOL)sendCommand:(NSString*)str completeTarget:(BOOL)completeTarget target:(N
else {
NSMutableArray* ignores = config.ignores;
for (int i=ignores.count-1; i>=0; --i) {
- IgnoreItem* e = [ignores objectAtIndex:i];
+ IgnoreItem* e = ignores[i];
if ([g isEqual:e]) {
[ignores removeObjectAtIndex:i];
[world save];
@@ -1672,7 +1672,7 @@ - (void)send:(NSString*)str, ...
int count = ary.count;
for (int i=0; i<count; i++) {
- NSString* e = [ary objectAtIndex:i];
+ NSString* e = ary[i];
[s appendString:@" "];
if (i == count-1 && (e.length == 0 || [e hasPrefix:@":"] || [e contains:@" "])) {
[s appendString:@":"];
@@ -1714,7 +1714,7 @@ - (void)processCommandsInCommandQueue
CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
while (commandQueue.count) {
- TimerCommand* m = [commandQueue objectAtIndex:0];
+ TimerCommand* m = commandQueue[0];
if (m.time <= now) {
NSString* target = nil;
IRCChannel* c = [world findChannelByClientId:uid channelId:m.cid];
@@ -1732,7 +1732,7 @@ - (void)processCommandsInCommandQueue
}
if (commandQueue.count) {
- TimerCommand* m = [commandQueue objectAtIndex:0];
+ TimerCommand* m = commandQueue[0];
CFAbsoluteTime delta = m.time - CFAbsoluteTimeGetCurrent();
[commandQueueTimer start:delta];
}
@@ -2307,7 +2307,7 @@ - (int)numberOfChildren
- (id)childAtIndex:(int)index
{
- return [channels objectAtIndex:index];
+ return channels[index];
}
- (NSString*)label
@@ -2374,7 +2374,7 @@ - (void)hostResolver:(HostResolver*)sender didResolve:(NSHost*)host
{
NSArray* addresses = [host addresses];
if (addresses.count) {
- NSString* address = [addresses objectAtIndex:0];
+ NSString* address = addresses[0];
[myAddress release];
myAddress = [address retain];
}
@@ -2614,8 +2614,8 @@ - (void)receiveCTCPQuery:(IRCMessage*)m text:(NSString*)text
}
else if ([command isEqualToString:VERSION]) {
NSDictionary* info = [[NSBundle mainBundle] infoDictionary];
- NSString* name = [info objectForKey:@"LCApplicationName"];
- NSString* ver = [info objectForKey:@"CFBundleShortVersionString"];
+ NSString* name = info[@"LCApplicationName"];
+ NSString* ver = info[@"CFBundleShortVersionString"];
NSString* text = [NSString stringWithFormat:@"%@ %@", name, ver];
[self sendCTCPReply:nick command:command text:text];
}
@@ -3617,7 +3617,7 @@ - (void)receiveNickCollisionError:(IRCMessage*)m
NSArray* altNicks = config.altNicks;
if (tryingNickNumber < altNicks.count) {
- NSString* nick = [altNicks objectAtIndex:tryingNickNumber];
+ NSString* nick = altNicks[tryingNickNumber];
[self send:NICK, nick, nil];
}
else {
View
40 Classes/IRC/IRCClientConfig.m
@@ -158,51 +158,51 @@ - (NSMutableDictionary*)dictionaryValue
{
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
- if (name) [dic setObject:name forKey:@"name"];
+ if (name) dic[@"name"] = name;
- if (host) [dic setObject:host forKey:@"host"];
+ if (host) dic[@"host"] = host;
[dic setInt:port forKey:@"port"];
[dic setBool:useSSL forKey:@"ssl"];
- if (nick) [dic setObject:nick forKey:@"nick"];
- if (password) [dic setObject:password forKey:@"password"];
- if (username) [dic setObject:username forKey:@"username"];
- if (realName) [dic setObject:realName forKey:@"realname"];
- if (nickPassword) [dic setObject:nickPassword forKey:@"nickPassword"];
+ if (nick) dic[@"nick"] = nick;
+ if (password) dic[@"password"] = password;
+ if (username) dic[@"username"] = username;
+ if (realName) dic[@"realname"] = realName;
+ if (nickPassword) dic[@"nickPassword"] = nickPassword;
[dic setBool:useSASL forKey:@"useSASL"];
- if (altNicks) [dic setObject:altNicks forKey:@"alt_nicks"];
+ if (altNicks) dic[@"alt_nicks"] = altNicks;
[dic setInt:proxyType forKey:@"proxy"];
- if (proxyHost) [dic setObject:proxyHost forKey:@"proxy_host"];
+ if (proxyHost) dic[@"proxy_host"] = proxyHost;
[dic setInt:proxyPort forKey:@"proxy_port"];
- if (proxyUser) [dic setObject:proxyUser forKey:@"proxy_user"];
- if (proxyPassword) [dic setObject:proxyPassword forKey:@"proxy_password"];
+ if (proxyUser) dic[@"proxy_user"] = proxyUser;
+ if (proxyPassword) dic[@"proxy_password"] = proxyPassword;
[dic setBool:autoConnect forKey:@"auto_connect"];
[dic setInt:encoding forKey:@"encoding"];
[dic setInt:fallbackEncoding forKey:@"fallback_encoding"];
- if (leavingComment) [dic setObject:leavingComment forKey:@"leaving_comment"];
- if (userInfo) [dic setObject:userInfo forKey:@"userinfo"];
+ if (leavingComment) dic[@"leaving_comment"] = leavingComment;
+ if (userInfo) dic[@"userinfo"] = userInfo;
[dic setBool:invisibleMode forKey:@"invisible"];
- if (altNicks) [dic setObject:loginCommands forKey:@"login_commands"];
+ if (loginCommands) dic[@"login_commands"] = loginCommands;
NSMutableArray* channelAry = [NSMutableArray array];
for (IRCChannelConfig* e in channels) {
[channelAry addObject:[e dictionaryValue]];
}
- [dic setObject:channelAry forKey:@"channels"];
-
- [dic setObject:autoOp forKey:@"autoop"];
-
+ dic[@"channels"] = channelAry;
+
+ dic[@"autoop"] = autoOp;
+
NSMutableArray* ignoreAry = [NSMutableArray array];
for (IgnoreItem* e in ignores) {
if (e.isValid) {
[ignoreAry addObject:[e dictionaryValue]];
}
}
- [dic setObject:ignoreAry forKey:@"ignores"];
-
+ dic[@"ignores"] = ignoreAry;
+
return dic;
}
View
2  Classes/IRC/IRCConnection.m
@@ -165,7 +165,7 @@ - (void)tryToSend
if (sending) return;
if (penalty > PENALTY_THREASHOLD) return;
- NSString* s = [sendQueue objectAtIndex:0];
+ NSString* s = sendQueue[0];
s = [s stringByAppendingString:@"\r\n"];
[sendQueue removeObjectAtIndex:0];
View
2  Classes/IRC/IRCISupportInfo.m
@@ -190,7 +190,7 @@ - (void)parseChanmodes:(NSString*)str
int count = ary.count;
for (int i=0; i<count; i++) {
- NSString* s = [ary objectAtIndex:i];
+ NSString* s = ary[i];
int len = s.length;
for (int j=0; j<len; j++) {
UniChar c = [s characterAtIndex:j];
View
4 Classes/IRC/IRCMessage.m
@@ -119,7 +119,7 @@ - (void)parseLine:(NSString*)line
- (NSString*)paramAt:(int)index
{
if (index < params.count) {
- return [params objectAtIndex:index];
+ return params[index];
}
else {
return @"";
@@ -137,7 +137,7 @@ - (NSString*)sequence:(int)index
int count = params.count;
for (int i=index; i<count; i++) {
- NSString* e = [params objectAtIndex:i];
+ NSString* e = params[i];
if (i != index) [s appendString:@" "];
[s appendString:e];
}
View
4 Classes/IRC/IRCSendingMessage.m
@@ -65,13 +65,13 @@ - (NSString*)string
int count = [params count];
if (count > 0) {
for (int i=0; i<count-1; ++i) {
- NSString* s = [params objectAtIndex:i];
+ NSString* s = params[i];
[d appendString:@" "];
[d appendString:s];
}
[d appendString:@" "];
- NSString* s = [params objectAtIndex:count-1];
+ NSString* s = params[count-1];
int len = s.length;
BOOL firstColonOrSpace = NO;
if (len > 0) {
View
32 Classes/IRC/IRCWorld.m
@@ -13,7 +13,7 @@
#define RECONNECT_AFTER_WAKE_UP_DELAY 8
#define TREE_DRAG_ITEM_TYPE @"tree"
-#define TREE_DRAG_ITEM_TYPES [NSArray arrayWithObject:TREE_DRAG_ITEM_TYPE]
+#define TREE_DRAG_ITEM_TYPES @[TREE_DRAG_ITEM_TYPE]
@interface IRCWorld (Private)
@@ -140,8 +140,8 @@ - (NSMutableDictionary*)dictionaryValue
for (IRCClient* u in clients) {
[ary addObject:[u dictionaryValue]];
}
-
- [dic setObject:ary forKey:@"clients"];
+
+ dic[@"clients"] = ary;
return dic;
}
@@ -532,7 +532,7 @@ - (void)selectChannelAt:(int)n
else {
--n;
if (0 <= n && n < c.channels.count) {
- IRCChannel* e = [c.channels objectAtIndex:n];
+ IRCChannel* e = c.channels[n];
[self select:e];
}
}
@@ -541,7 +541,7 @@ - (void)selectChannelAt:(int)n
- (void)selectClientAt:(int)n
{
if (0 <= n && n < clients.count) {
- IRCClient* c = [clients objectAtIndex:n];
+ IRCClient* c = clients[n];
IRCChannel* e = c.lastSelectedChannel;
if (e) {
[self select:e];
@@ -720,7 +720,7 @@ - (void)selectOtherAndDestroy:(IRCTreeItem*)target
i = [clients indexOfObjectIdenticalTo:target];
int n = i + 1;
if (0 <= n && n < clients.count) {
- sel = [clients objectAtIndex:n];
+ sel = clients[n];
}
i = [tree rowForItem:target];
}
@@ -858,10 +858,10 @@ - (void)logDoubleClick:(NSString*)s
{
NSArray* ary = [s componentsSeparatedByString:@" "];
if (ary.count) {
- NSString* kind = [ary objectAtIndex:0];
+ NSString* kind = ary[0];
if ([kind isEqualToString:@"client"]) {
if (ary.count >= 2) {
- int uid = [[ary objectAtIndex:1] intValue];
+ int uid = [ary[1] intValue];
IRCClient* u = [self findClientById:uid];
if (u) {
[self select:u];
@@ -870,8 +870,8 @@ - (void)logDoubleClick:(NSString*)s
}
else if ([kind isEqualToString:@"channel"]) {
if (ary.count >= 3) {
- int uid = [[ary objectAtIndex:1] intValue];
- int cid = [[ary objectAtIndex:2] intValue];
+ int uid = [ary[1] intValue];
+ int cid = [ary[2] intValue];
IRCChannel* c = [self findChannelByClientId:uid channelId:cid];
if (c) {
[self select:c];
@@ -932,7 +932,7 @@ - (BOOL)outlineView:(NSOutlineView *)sender isItemExpandable:(id)item
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(IRCTreeItem*)item
{
- if (!item) return [clients objectAtIndex:index];
+ if (!item) return clients[index];
return [item childAtIndex:index];
}
@@ -1039,7 +1039,7 @@ - (BOOL)outlineView:(NSOutlineView *)sender writeItems:(NSArray *)items toPasteb
if (!items.count) return NO;
NSString* s;
- IRCTreeItem* i = [items objectAtIndex:0];
+ IRCTreeItem* i = items[0];
if (i.isClient) {
IRCClient* u = (IRCClient*)i;
s = [NSString stringWithFormat:@"%d", u.uid];
@@ -1058,8 +1058,8 @@ - (IRCTreeItem*)findItemFromInfo:(NSString*)s
{
if ([s contains:@"-"]) {
NSArray* ary = [s componentsSeparatedByString:@"-"];
- int uid = [[ary objectAtIndex:0] intValue];
- int cid = [[ary objectAtIndex:1] intValue];
+ int uid = [ary[0] intValue];
+ int cid = [ary[1] intValue];
return [self findChannelByClientId:uid channelId:cid];
}
else {
@@ -1104,7 +1104,7 @@ - (NSDragOperation)outlineView:(NSOutlineView *)sender validateDrop:(id < NSDrag
else {
// do not allow drop talk between channels
if (high.count) {
- IRCChannel* next = [high objectAtIndex:0];
+ IRCChannel* next = high[0];
if (next.isChannel) return NSDragOperationNone;
}
}
@@ -1183,7 +1183,7 @@ - (void)memberListViewDropFiles:(NSArray*)files row:(NSNumber*)row
IRCChannel* c = self.selectedChannel;
if (!u || !c) return;
- IRCUser* m = [c.members objectAtIndex:[row intValue]];
+ IRCUser* m = c.members[[row intValue]];
if (m) {
for (NSString* s in files) {
[dcc addSenderWithUID:u.uid nick:m.nick fileName:s autoOpen:YES];
View
6 Classes/IRC/IRCWorldConfig.m
@@ -52,10 +52,10 @@ - (NSMutableDictionary*)dictionaryValue
for (IRCClientConfig* e in clients) {
[clientAry addObject:[e dictionaryValue]];
}
- [dic setObject:clientAry forKey:@"clients"];
-
- [dic setObject:autoOp forKey:@"autoop"];
+ dic[@"clients"] = clientAry;
+ dic[@"autoop"] = autoOp;
+
return dic;
}
View
18 Classes/IRC/IgnoreItem.m
@@ -36,11 +36,11 @@ - (id)initWithDictionary:(NSDictionary*)dic
{
self = [self init];
if (self) {
- nick = [[dic objectForKey:@"nick"] retain];
- text = [[dic objectForKey:@"text"] retain];
+ nick = [dic[@"nick"] retain];
+ text = [dic[@"text"] retain];
useRegexForNick = [dic boolForKey:@"useRegexForNick"];
useRegexForText = [dic boolForKey:@"useRegexForText"];
- channels = [[dic objectForKey:@"channels"] retain];
+ channels = [dic[@"channels"] retain];
}
return self;
}
@@ -49,13 +49,13 @@ - (NSDictionary*)dictionaryValue
{
NSMutableDictionary* dic = [NSMutableDictionary dictionary];
- if (nick) [dic setObject:nick forKey:@"nick"];
- if (text) [dic setObject:text forKey:@"text"];
-
- [dic setBool:useRegexForNick forKey:@"useRegexForNick"];
- [dic setBool:useRegexForText forKey:@"useRegexForText"];
+ if (nick) dic[@"nick"] = nick;
+ if (text) dic[@"text"] = text;
+
+ dic[@"useRegexForNick"] = [NSNumber numberWithBool:useRegexForNick];
+ dic[@"useRegexForText"] = [NSNumber numberWithBool:useRegexForText];
- if (channels) [dic setObject:channels forKey:@"channels"];
+ if (channels) dic[@"channels"] = channels;
return dic;
}
View
88 Classes/Library/AsyncSocket.m
@@ -571,7 +571,7 @@ - (id)initWithDelegate:(id)delegate userData:(long)userData
theContext.copyDescription = nil;
// Default run loop modes
- theRunLoopModes = [[NSArray arrayWithObject:NSDefaultRunLoopMode] retain];
+ theRunLoopModes = [@[NSDefaultRunLoopMode] retain];
}
return self;
}
@@ -687,7 +687,7 @@ - (void)runLoopAddSource:(CFRunLoopSourceRef)source
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFRunLoopAddSource(theRunLoop, source, runLoopMode);
}
}
@@ -697,7 +697,7 @@ - (void)runLoopRemoveSource:(CFRunLoopSourceRef)source
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFRunLoopRemoveSource(theRunLoop, source, runLoopMode);
}
}
@@ -707,7 +707,7 @@ - (void)runLoopAddTimer:(NSTimer *)timer
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFRunLoopAddTimer(theRunLoop, (CFRunLoopTimerRef)timer, runLoopMode);
}
}
@@ -717,7 +717,7 @@ - (void)runLoopRemoveTimer:(NSTimer *)timer
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFRunLoopRemoveTimer(theRunLoop, (CFRunLoopTimerRef)timer, runLoopMode);
}
}
@@ -727,7 +727,7 @@ - (void)runLoopUnscheduleReadStream
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFReadStreamUnscheduleFromRunLoop(theReadStream, theRunLoop, runLoopMode);
}
CFReadStreamSetClient(theReadStream, kCFStreamEventNone, NULL, NULL);
@@ -738,7 +738,7 @@ - (void)runLoopUnscheduleWriteStream
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFWriteStreamUnscheduleFromRunLoop(theWriteStream, theRunLoop, runLoopMode);
}
CFWriteStreamSetClient(theWriteStream, kCFStreamEventNone, NULL, NULL);
@@ -992,8 +992,8 @@ - (BOOL)acceptOnInterface:(NSString *)interface port:(UInt16)port error:(NSError
if(errPtr)
{
NSString *errMsg = [NSString stringWithCString:gai_strerror(error) encoding:NSASCIIStringEncoding];
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
*errPtr = [NSError errorWithDomain:@"kCFStreamErrorDomainNetDB" code:error userInfo:info];
}
}
@@ -1573,7 +1573,7 @@ - (BOOL)attachStreamsToRunLoop:(NSRunLoop *)runLoop error:(NSError **)errPtr
NSUInteger i, count = [theRunLoopModes count];
for(i = 0; i < count; i++)
{
- CFStringRef runLoopMode = (CFStringRef)[theRunLoopModes objectAtIndex:i];
+ CFStringRef runLoopMode = (CFStringRef)theRunLoopModes[i];
CFReadStreamScheduleWithRunLoop(theReadStream, theRunLoop, runLoopMode);
CFWriteStreamScheduleWithRunLoop(theWriteStream, theRunLoop, runLoopMode);
}
@@ -2001,8 +2001,8 @@ - (NSData *)unreadData
- (NSError *)getErrnoError
{
NSString *errorMsg = [NSString stringWithUTF8String:strerror(errno)];
- NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errorMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *userInfo = @{NSLocalizedDescriptionKey: errorMsg};
+
return [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:userInfo];
}
@@ -2016,8 +2016,8 @@ - (NSError *)getSocketError
@"AsyncSocket", [NSBundle mainBundle],
@"General CFSocket error", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketCFSocketError userInfo:info];
}
@@ -2048,8 +2048,8 @@ - (NSError *)getAbortError
@"AsyncSocket", [NSBundle mainBundle],
@"Connection canceled", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketCanceledError userInfo:info];
}
@@ -2062,8 +2062,8 @@ - (NSError *)getConnectTimeoutError
@"AsyncSocket", [NSBundle mainBundle],
@"Attempt to connect to host timed out", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketConnectTimeoutError userInfo:info];
}
@@ -2076,8 +2076,8 @@ - (NSError *)getReadMaxedOutError
@"AsyncSocket", [NSBundle mainBundle],
@"Read operation reached set maximum length", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketReadMaxedOutError userInfo:info];
}
@@ -2090,8 +2090,8 @@ - (NSError *)getReadTimeoutError
@"AsyncSocket", [NSBundle mainBundle],
@"Read operation timed out", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketReadTimeoutError userInfo:info];
}
@@ -2104,8 +2104,8 @@ - (NSError *)getWriteTimeoutError
@"AsyncSocket", [NSBundle mainBundle],
@"Write operation timed out", nil);
- NSDictionary *info = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
-
+ NSDictionary *info = @{NSLocalizedDescriptionKey: errMsg};
+
return [NSError errorWithDomain:AsyncSocketErrorDomain code:AsyncSocketWriteTimeoutError userInfo:info];
}
@@ -2147,7 +2147,7 @@ - (NSError *)errorFromCFStreamError:(CFStreamError)err
NSDictionary *info = nil;
if(message != nil)
{
- info = [NSDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey];
+ info = @{NSLocalizedDescriptionKey: message};
}
return [NSError errorWithDomain:domain code:err.error userInfo:info];
}
@@ -2961,7 +2961,7 @@ - (void)maybeDequeueRead
if([theReadQueue count] > 0)
{
// Dequeue the next object in the write queue
- theCurrentRead = [[theReadQueue objectAtIndex:0] retain];
+ theCurrentRead = [theReadQueue[0] retain];
[theReadQueue removeObjectAtIndex:0];
if([theCurrentRead isKindOfClass:[AsyncSpecialPacket class]])
@@ -3395,7 +3395,7 @@ - (void)maybeDequeueWrite
if([theWriteQueue count] > 0)
{
// Dequeue the next object in the write queue
- theCurrentWrite = [[theWriteQueue objectAtIndex:0] retain];
+ theCurrentWrite = [theWriteQueue[0] retain];
[theWriteQueue removeObjectAtIndex:0];
if([theCurrentWrite isKindOfClass:[AsyncSpecialPacket class]])
@@ -3751,14 +3751,14 @@ - (void)doCFWriteStreamCallback:(CFStreamEventType)type forStream:(CFWriteStream
- (void)useSSL
{
- NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
- (NSString*)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamSSLLevel,
- kCFBooleanTrue, kCFStreamSSLAllowsAnyRoot,
- kCFBooleanFalse, kCFStreamSSLValidatesCertificateChain,
- kCFNull, kCFStreamSSLPeerName,
- kCFBooleanFalse, kCFStreamSSLIsServer,
- nil];
-
+ NSDictionary* settings = @{
+ (id)kCFStreamSSLLevel: (id)kCFStreamSocketSecurityLevelNegotiatedSSL,
+ (id)kCFStreamSSLAllowsAnyRoot: (id)kCFBooleanTrue,
+ (id)kCFStreamSSLValidatesCertificateChain: (id)kCFBooleanFalse,
+ (id)kCFStreamSSLPeerName: (id)kCFNull,
+ (id)kCFStreamSSLIsServer: (id)kCFBooleanFalse,
+ };
+
CFReadStreamSetProperty(theReadStream, kCFStreamPropertySSLSettings, settings);
CFWriteStreamSetProperty(theWriteStream, kCFStreamPropertySSLSettings, settings);
}
@@ -3776,17 +3776,21 @@ - (void)useSocksProxyVersion:(int)version host:(NSString*)host port:(int)port us
NSMutableDictionary* settings = [NSMutableDictionary dictionary];
if (version == 4) {
- [settings setObject:(NSString*)kCFStreamSocketSOCKSVersion4 forKey:(NSString*)kCFStreamPropertySOCKSVersion];
+ settings[(NSString*)kCFStreamPropertySOCKSVersion] = (NSString*)kCFStreamSocketSOCKSVersion4;
}
else {
- [settings setObject:(NSString*)kCFStreamSocketSOCKSVersion5 forKey:(NSString*)kCFStreamPropertySOCKSVersion];
+ settings