{"id":11296,"date":"2015-05-23T09:16:49","date_gmt":"2015-05-23T13:16:49","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=11296"},"modified":"2015-05-23T09:16:49","modified_gmt":"2015-05-23T13:16:49","slug":"how-not-to-crash-3-nsnotification","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/05\/23\/how-not-to-crash-3-nsnotification\/","title":{"rendered":"How Not to Crash #3: NSNotification"},"content":{"rendered":"<p><a href=\"http:\/\/inessential.com\/2015\/05\/21\/how_not_to_crash_3_nsnotification\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/inessential.com\/2015\/05\/21\/how_not_to_crash_3_nsnotification\">\n<p>I have one simple, hard-and-fast rule: NSNotifications are posted <em>on the main thread only<\/em>. No exceptions. If some code is running in another thread and it needs to post a notification, it does so on the main thread.<\/p>\n<p>[&#8230;]<\/p>\n<p>Your notification handlers should be written so that they can deal with getting called twice. And it should be impossible for a given object to register twice for the same notification. Both.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: I have one simple, hard-and-fast rule: NSNotifications are posted on the main thread only. No exceptions. If some code is running in another thread and it needs to post a notification, it does so on the main thread. [&#8230;] Your notification handlers should be written so that they can deal with getting called [&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,800,31,30,54,71],"class_list":["post-11296","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-concurrency","tag-ios","tag-mac","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11296","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=11296"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11296\/revisions"}],"predecessor-version":[{"id":11297,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/11296\/revisions\/11297"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=11296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=11296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=11296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}