{"id":27844,"date":"2020-01-10T14:47:31","date_gmt":"2020-01-10T19:47:31","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=27844"},"modified":"2020-01-10T14:47:31","modified_gmt":"2020-01-10T19:47:31","slug":"observing-appearance-changes","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/01\/10\/observing-appearance-changes\/","title":{"rendered":"Observing Appearance Changes"},"content":{"rendered":"<p><a href=\"https:\/\/www.jessesquires.com\/blog\/observing-appearance-changes-on-ios-and-macos\/\">Jesse Squires<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.jessesquires.com\/blog\/observing-appearance-changes-on-ios-and-macos\/\"><p>I needed to get notified when the system appearance changed. On iOS, this is very straight-forward and a first-class API. On iOS 13, the interface style is part of <a href=\"https:\/\/developer.apple.com\/documentation\/uikit\/uitraitcollection\"><code>UITraitCollection<\/code><\/a>.<\/p><p>[&#8230;]<\/p><p>[On macOS,] you can KVO on <a href=\"https:\/\/developer.apple.com\/documentation\/appkit\/nsapplication\/2967171-effectiveappearance\"><code>NSApp.effectiveappearance<\/code><\/a>. [&#8230;] Using KVO still does not feel great, but this is the best solution I could find without having an explicit API like iOS.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/01\/10\/kvo-my-enemy\/\">KVO, My Enemy<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/10\/08\/supporting-dark-mode\/\">Supporting Dark Mode<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jesse Squires: I needed to get notified when the system appearance changed. On iOS, this is very straight-forward and a first-class API. On iOS 13, the interface style is part of UITraitCollection.[&#8230;][On macOS,] you can KVO on NSApp.effectiveappearance. [&#8230;] Using KVO still does not feel great, but this is the best solution I could find [&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:35Z","apple_news_api_id":"ab51f109-1ef9-4573-a5c1-bda4ee49f14c","apple_news_api_modified_at":"2020-01-10T19:47:35Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/Aq1HxCR75RXOlwb2k7knxTA","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,1805,31,1667,275,30,1666,71],"class_list":["post-27844","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-dark-mode","tag-ios","tag-ios-13","tag-keyvalueobserving","tag-mac","tag-macos-10-15","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27844","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=27844"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27844\/revisions"}],"predecessor-version":[{"id":27845,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27844\/revisions\/27845"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=27844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=27844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=27844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}