{"id":27842,"date":"2020-01-10T14:47:19","date_gmt":"2020-01-10T19:47:19","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=27842"},"modified":"2023-02-10T10:44:53","modified_gmt":"2023-02-10T15:44:53","slug":"kvo-my-enemy","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/01\/10\/kvo-my-enemy\/","title":{"rendered":"KVO, My Enemy"},"content":{"rendered":"<p><a href=\"https:\/\/inessential.com\/2019\/12\/30\/kvo_my_enemy\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/inessential.com\/2019\/12\/30\/kvo_my_enemy\">\n<p>One of the keys to the stability of the shipping versions of NetNewsWire is that we don&rsquo;t allow KVO (Key-Value Observing).<\/p>\n<p>KVO is a false convenience &mdash; it&rsquo;s often easier than setting up a delegate or old-fashioned notification. But to use KVO is to just ask for your app to crash.<\/p>\n<p>And not just crash, but crash in hard-to-figure-out ways.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/github.com\/Ranchero-Software\/NetNewsWire\/issues\/1481#issuecomment-570772838\">Drew McCormack<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/Ranchero-Software\/NetNewsWire\/issues\/1481#issuecomment-570772838\"><p>As others point out, there are a bunch of issues with the FeedlyOperation class, such as the isAsynchronous override, and not changing to the final state atomically. But I think maybe the biggest problem is the use of Swift key paths. Not sure if that should be supported, but in my testing, it doesn&rsquo;t work. Changing to strings for the key paths fixed things for me.<\/p><\/blockquote>\n<p>I&rsquo;m not sure what the issue is&mdash;perhaps a Swift bug or incorrect property declarations so that there&rsquo;s disagreement about whether <code>is<\/code> is part of the property name&mdash;but Swift key paths seem to be a common source of problems.<\/p>\n\n<p><a href=\"https:\/\/github.com\/Ranchero-Software\/NetNewsWire\/issues\/1481#issuecomment-572195484\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/Ranchero-Software\/NetNewsWire\/issues\/1481#issuecomment-572195484\"><p>We&rsquo;re going to write a replacement for OperationQueue. <\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/11\/02\/the-power-of-key-paths-in-swift\/\">The Power of Key Paths in Swift<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/06\/27\/sr-7380-ambiguous-keypath\/\">SR-7380, Ambiguous KeyPath<\/a><\/li>\n<\/ul>\n\n<p id=\"kvo-my-enemy-update-2020-01-24\">Update (2020-01-24): <a href=\"https:\/\/twitter.com\/galooticus\/status\/1215729296808873984\">Adam Maxwell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/galooticus\/status\/1215729296808873984\">\n<p>If \n@brentsimmons\n is writing an NSOperationQueue replacement, I did that <a href=\"https:\/\/github.com\/amaxwell\/fileview\">a few years ago<\/a>, for deployment to Leopard.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/inessential.com\/2020\/01\/20\/on_replacing_operationqueue\">Brent Simmons<\/a> (<a href=\"https:\/\/twitter.com\/brentsimmons\/status\/1219363495864602624\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/inessential.com\/2020\/01\/20\/on_replacing_operationqueue\">\n<p>We fixed our <a href=\"https:\/\/inessential.com\/2019\/12\/30\/kvo_my_enemy\">mystery KVO crash<\/a> by writing a replacement for <code>OperationQueue.<\/code><\/p>\n<p>[&#8230;]<\/p>\n<p><a href=\"https:\/\/github.com\/Ranchero-Software\/RSCore\/blob\/master\/RSCore\/MainThreadOperationQueue.swift\">MainThreadOperationQueue<\/a> and <a href=\"https:\/\/github.com\/Ranchero-Software\/RSCore\/blob\/master\/RSCore\/MainThreadOperation.swift\">MainThreadOperation<\/a> are part of our RSCore framework.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Brent Simmons: One of the keys to the stability of the shipping versions of NetNewsWire is that we don&rsquo;t allow KVO (Key-Value Observing). KVO is a false convenience &mdash; it&rsquo;s often easier than setting up a delegate or old-fashioned notification. But to use KVO is to just ask for your app to crash. And not [&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":"2020-01-10T19:47:21Z","apple_news_api_id":"592ffc78-0eb2-417d-bf1a-f7c7a0f1ab9d","apple_news_api_modified_at":"2023-02-10T15:44:56Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAg==","apple_news_api_share_url":"https:\/\/apple.news\/AWS_8eA6yQX2_GvfHoPGrnQ","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,56,275,30,1666,571,392,71,901],"class_list":["post-27842","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-concurrency","tag-debugging","tag-keyvalueobserving","tag-mac","tag-macos-10-15","tag-memory-management","tag-netnewswire","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27842","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=27842"}],"version-history":[{"count":4,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27842\/revisions"}],"predecessor-version":[{"id":38429,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27842\/revisions\/38429"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=27842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=27842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=27842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}