{"id":8224,"date":"2013-11-20T10:55:47","date_gmt":"2013-11-20T15:55:47","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8224"},"modified":"2013-11-20T10:55:47","modified_gmt":"2013-11-20T15:55:47","slug":"nsnotificationcenter-with-blocks-considered-harmful","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/11\/20\/nsnotificationcenter-with-blocks-considered-harmful\/","title":{"rendered":"NSNotificationCenter With Blocks Considered Harmful"},"content":{"rendered":"<p>Great post from <a href=\"http:\/\/sealedabstract.com\/code\/nsnotificationcenter-with-blocks-considered-harmful\/\">Drew Crawford<\/a>:<\/p>\n<blockquote cite=\"http:\/\/sealedabstract.com\/code\/nsnotificationcenter-with-blocks-considered-harmful\/\"><p>This could be, I think, the <strong>single biggest API blunder<\/strong> in iOS. (Except maybe iCloud Core Data.) I have debugged issues that were root-caused to this misleading API <em>more than ten times<\/em>. I have lost <em>more than four weeks<\/em> to this API. I have <em>no less than six<\/em> radars open about it.<\/p>\n<p>[&#8230;]<\/p>\n<p>The documentation lists no fewer than <strong>six<\/strong> sample code projects underneath the Notifications-with-blocks API. And <strong>five out of six Apple model projects<\/strong> are wrong. Let that sink in.<\/p>\n<\/blockquote>\n<p>It&rsquo;s exacerbated by documentation bugs\/omissions, such as that <code>NSAssert<\/code> should not be used in blocks. He links to two alternative APIs, <a href=\"https:\/\/github.com\/nicklockwood\/FXNotifications\">FXNotifications<\/a> (which uses swizzling) and <a href=\"https:\/\/github.com\/jwilling\/NSNotificationCenter-JNWBlocks\">NSNotificationCenter-JNWBlocks<\/a> (which uses associated objects). Both use weak object references, which means they won&rsquo;t work on Mac OS X 10.6.<\/p>","protected":false},"excerpt":{"rendered":"<p>Great post from Drew Crawford: This could be, I think, the single biggest API blunder in iOS. (Except maybe iCloud Core Data.) I have debugged issues that were root-caused to this misleading API more than ten times. I have lost more than four weeks to this API. I have no less than six radars open [&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":[55,168,69,31,30,54,71],"class_list":["post-8224","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-arc","tag-blocks","tag-cocoa","tag-ios","tag-mac","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8224","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=8224"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8224\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}