Permalink
Browse files

Use new literal syntax

  • Loading branch information...
1 parent 6582f18 commit c17060d99e3e0c1cc98c0340cb39355b14481d80 @psychs committed Jul 27, 2012
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
@@ -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];
}
}
@@ -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) {
@@ -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];
}
}
@@ -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];
}
}
Oops, something went wrong.

0 comments on commit c17060d

Please sign in to comment.