{"id":310,"date":"2009-05-15T14:13:02","date_gmt":"2009-05-15T19:13:02","guid":{"rendered":"http:\/\/vgable.com\/blog\/2009\/05\/15\/concise-nsdictionary-and-nsarray-lookup\/"},"modified":"2009-05-15T14:13:04","modified_gmt":"2009-05-15T19:13:04","slug":"concise-nsdictionary-and-nsarray-lookup","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2009\/05\/15\/concise-nsdictionary-and-nsarray-lookup\/","title":{"rendered":"Concise NSDictionary and NSArray Lookup"},"content":{"rendered":"<p>I started writing a list of ways I thought Objective-C could be improved, and I realized that many of my wishes involved more compact syntax. For example <code>[array objectAtIndex:1]<\/code> is so verbose I think it diminishes readability, compared to <code>array[1]<\/code>.<\/p>\n<p>I can&#8217;t quite match that brevity (can you, by using Objective-C++?), but with a one-line category, you can say, <code>x = [array:1];<\/code>.<\/p>\n<pre>\n@interface NSArray (ConciseLookup)\n- (id):(NSUInteger)index;\n@end\n@implementation NSArray (ConciseLookup)\n- (id):(NSUInteger)index;\n{\n\treturn [self objectAtIndex:index];\n}\n@end\n<\/pre>\n<p>My question is: <strong>do you find this compact &#8220;syntax&#8221; useful at all, or is it added complexity with no substantial code compression?<\/strong> Personally I think the latter, but the number of wishes I had involving  more concise Objective-C syntax makes me wonder&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I started writing a list of ways I thought Objective-C could be improved, and I realized that many of my wishes involved more compact syntax. For example [array objectAtIndex:1] is so verbose I think it diminishes readability, compared to array[1]. I can&#8217;t quite match that brevity (can you, by using Objective-C++?), but with a one-line [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4,11,13,8],"tags":[107,108,417],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-objective-c","category-programming","category-research","category-sample-code","category-usability","tag-nsarray","tag-nsdictionary","tag-programming-language-design"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=310"}],"version-history":[{"count":0,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/310\/revisions"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}