{"id":1785,"date":"2008-09-24T18:51:26","date_gmt":"2008-09-24T22:51:26","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=1785"},"modified":"2008-09-24T18:51:32","modified_gmt":"2008-09-24T22:51:32","slug":"kvo-issue-with-subclassing","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2008\/09\/24\/kvo-issue-with-subclassing\/","title":{"rendered":"KVO Issue With Subclassing"},"content":{"rendered":"<p><a href=\"http:\/\/blog.omnigroup.com\/2008\/09\/24\/kvo-issue-with-subclassing\/\">Tim Wood<\/a>:<\/p>\n<blockquote cite=\"http:\/\/blog.omnigroup.com\/2008\/09\/24\/kvo-issue-with-subclassing\/\"><p>The core of the problem is an API flaw in KVO; -removeObserver:forKeyPath: doesn&rsquo;t include a context argument. So, if you have an object that is subscribed to a key twice, with two different context pointers, it is undefined which will get removed. If your object is dying and cleaning up all observations, this isn&rsquo;t a big deal. But if your subclass logic wants to temporarily turn off its observation, it has no way to make sure that&rsquo;s what happens&mdash;it might instead end up removing the superclass observation.\n<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Tim Wood: The core of the problem is an API flaw in KVO; -removeObserver:forKeyPath: doesn&rsquo;t include a context argument. So, if you have an object that is subscribed to a key twice, with two different context pointers, it is undefined which will get removed. If your object is dying and cleaning up all observations, this [&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":[],"class_list":["post-1785","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1785","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=1785"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1785\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=1785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=1785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=1785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}