{"id":4529,"date":"2012-03-21T12:14:04","date_gmt":"2012-03-21T17:14:04","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=4529"},"modified":"2014-04-15T20:31:16","modified_gmt":"2014-04-16T00:31:16","slug":"objective-c-literals","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2012\/03\/21\/objective-c-literals\/","title":{"rendered":"Objective-C Literals"},"content":{"rendered":"<p>The updated <a href=\"http:\/\/clang.llvm.org\/docs\/ObjectiveCLiterals.html\">Clang documentation<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/clang.llvm.org\/docs\/ObjectiveCLiterals.html\"><p>Using array and dictionary literals is safer than the variadic creation forms commonly in use today. Array literal expressions expand to calls to <code>+[NSArray arrayWithObjects:count:]<\/code>, which validates that all objects are non-<code>nil<\/code>. The variadic form, <code>+[NSArray arrayWithObjects:]<\/code> uses <code>nil<\/code> as an argument list terminator, which can lead to malformed array objects. Dictionary literals are similarly created with <code>+[NSDictionary dictionaryWithObjects:forKeys:count:]<\/code> which validates all objects and keys, unlike <code>+[NSDictionary dictionaryWithObjectsAndKeys:]<\/code> which also uses a <code>nil<\/code> parameter as an argument list terminator.<\/p><\/blockquote>\r\n<p>There are lots of carrots for going 64-bit-only and adopting the modern Objective-C runtime.<\/p>","protected":false},"excerpt":{"rendered":"<p>The updated Clang documentation: Using array and dictionary literals is safer than the variadic creation forms commonly in use today. Array literal expressions expand to calls to +[NSArray arrayWithObjects:count:], which validates that all objects are non-nil. The variadic form, +[NSArray arrayWithObjects:] uses nil as an argument list terminator, which can lead to malformed array objects. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,859,860,54,71],"class_list":["post-4529","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-nsarray","tag-nsdictionary","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=4529"}],"version-history":[{"count":7,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4529\/revisions"}],"predecessor-version":[{"id":8707,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4529\/revisions\/8707"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=4529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=4529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=4529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}