{"id":37,"date":"2012-06-08T15:09:27","date_gmt":"2012-06-08T19:09:27","guid":{"rendered":"http:\/\/blog.blackgecko.com\/?p=37"},"modified":"2012-06-08T15:09:27","modified_gmt":"2012-06-08T19:09:27","slug":"the-literals-are-coming-the-literals-are-coming","status":"publish","type":"post","link":"http:\/\/blog.blackgecko.com\/?p=37","title":{"rendered":"The Literals are Coming, the Literals are Coming"},"content":{"rendered":"<p>It&#8217;s just days before WWDC and the rumors are flying about what Apple will introduce. Will it be iOS 6? new iPhone hardware? MacBook Pros? how about Mac Pros? One addition that isn&#8217;t actually a rumor but pretty much a confirmed fact is the addition of literals to Objective-C and the arrival of the Apple LLVM compiler.<\/p>\n<p>The cat escaped the bag back in March when Apple checked in code to the open source clang trunk, over at LLVM.org, adding capabilities to make literals possible. Along with checking in the code came some very nice <a title=\"documentation\" href=\"http:\/\/clang.llvm.org\/docs\/ObjectiveCLiterals.html\">documentation<\/a>\u00a0that details what literals mean for developers. <a title=\"The Big Nerd Ranch Weblog\" href=\"http:\/\/weblog.bignerdranch.com\/398-objective-c-literals-part-1\/\">The Big Nerd Ranch Weblog<\/a> followed the release by Apple with a slightly shorter explanation on literals.<\/p>\n<p>If you have the time I would definitely recommend reading the LLVM.org article. The\u00a0short version on literals is that Apple is bringing some of the comforts of Ruby to Objective-C by extending the\u00a0responsibilities\u00a0of the &#8216;@&#8217; symbole. The slightly longer version is the Apple is adding\u00a0syntactical\u00a0sugar to NSNumber, NSArray, and NSDictionary.<\/p>\n<p>For NSNumber Apple has simplified the process of creating them. You can now prepend a number with the &#8216;@&#8217; symbol and presto, you&#8217;ve got an NSNumber object. There isn&#8217;t an\u00a0equivalent\u00a0way to get your number back out of NSNumber but this is\u00a0definitely\u00a0a good start.<\/p>\n<p>For NSArray and NSDictionary Apple has added a bit of magic too. Now you can create an NSArray by putting your array inside a &#8216;@[]&#8217; and an NSDictionary by putting your dictionary inside a &#8216;@{}&#8217;. Unlike NSNumber Apple added a nice way to get data back out of both NSArray and NSDictionary. The secret is &#8216;[]&#8217;. You put square brakets after either your NSArray or NSDictionary and then put your index, either number or object, inside the square brackets.<\/p>\n<p>If you&#8217;re feeling particularly\u00a0adventures\u00a0you can download the current build of both llvm and clang from <a title=\"LLVM.org\" href=\"http:\/\/llvm.org\/releases\/\">LLVM.org<\/a>.\u00a0Unfortunately\u00a0at the moment Xcode doesn&#8217;t have these new features but wait a moment, well at least until Monday, and you&#8217;ll have Objective-C with Literals.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s just days before WWDC and the rumors are flying about what Apple will introduce. Will it be iOS 6? new iPhone hardware? MacBook Pros? how about Mac Pros? One addition that isn&#8217;t actually a rumor but pretty much a &hellip; <a href=\"http:\/\/blog.blackgecko.com\/?p=37\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,6,8],"tags":[],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-clang","category-llvm","category-objective-c","category-programming"],"_links":{"self":[{"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":2,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":41,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions\/41"}],"wp:attachment":[{"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.blackgecko.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}