{"id":18412,"date":"2017-07-20T16:03:32","date_gmt":"2017-07-20T20:03:32","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=18412"},"modified":"2017-07-20T16:17:51","modified_gmt":"2017-07-20T20:17:51","slug":"swift-4-key-value-observation","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/07\/20\/swift-4-key-value-observation\/","title":{"rendered":"Swift 4: Key-Value Observation"},"content":{"rendered":"<p><a href=\"http:\/\/skyefreeman.io\/programming\/2017\/06\/28\/kvo-in-ios11.html\">Skye Freeman<\/a>:<\/p>\n<blockquote cite=\"http:\/\/skyefreeman.io\/programming\/2017\/06\/28\/kvo-in-ios11.html\">\n<p>One of the most exciting additions to the Foundation library in iOS 11 that somehow flew under my radar was the new Swift syntax for key value observation. It&rsquo;s long been known that the KVO API was one of the more obfuscated and confusing in Cocoa, which makes this change so exciting. Not only is it type safe, but also terse as hell[&#8230;]<\/p>\n<p>[&#8230;]<\/p>\n<pre>let observation = foo.observe(\\.string) { (foo, change) in\n    print(\"new foo.string: \\(foo.string)\")\n}<\/pre>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Skye Freeman: One of the most exciting additions to the Foundation library in iOS 11 that somehow flew under my radar was the new Swift syntax for key value observation. It&rsquo;s long been known that the KVO API was one of the more obfuscated and confusing in Cocoa, which makes this change so exciting. 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":"","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,31,1472,275,30,1529,71,901],"class_list":["post-18412","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-ios-11","tag-keyvalueobserving","tag-mac","tag-macos-10-13","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18412","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=18412"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18412\/revisions"}],"predecessor-version":[{"id":18423,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18412\/revisions\/18423"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=18412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=18412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=18412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}