{"id":17665,"date":"2017-04-06T15:17:49","date_gmt":"2017-04-06T19:17:49","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=17665"},"modified":"2017-04-06T15:17:49","modified_gmt":"2017-04-06T19:17:49","slug":"putting-core-data-on-the-map","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/04\/06\/putting-core-data-on-the-map\/","title":{"rendered":"Putting Core Data on the Map"},"content":{"rendered":"<p><a href=\"http:\/\/timekl.com\/blog\/2017\/04\/02\/putting-core-data-on-the-map\/\">Tim Ekl<\/a>:<\/p>\n<blockquote cite=\"http:\/\/timekl.com\/blog\/2017\/04\/02\/putting-core-data-on-the-map\/\"><p>The Core Data setup was fairly straightforward: I wanted Point to store latitude, longitude, and title, so I added two numeric and one string attribute to the Point entity. [&#8230;] Right off the bat, it seemed like the easiest thing to do was to make the Point\ninstances themselves conform to MKAnnotation. They already had <code>latitude<\/code>,\n<code>longitude<\/code>, and <code>title<\/code>; all that was left was to merge the former into a\n<code>coordinate<\/code> property.<\/p><p>[&#8230;]<\/p><p>In testing, though, this soured quickly: a critical operation in everyday use was deleting a Point from the database. However, telling the map view to remove a Point annotation wasn&rsquo;t quite as prompt as it should have been. Annotations would remain on the map for a few seconds, or in rare cases much longer.<\/p><p>[&#8230;]<\/p><p>In the &ldquo;Discussion&rdquo; section of the docs for <code>MKAnnotation.coordinate<\/code>, there\nexists this critical qualifier [&#8230;] As soon as I noticed this, everything clicked: the map was likely using KVO to watch for changes in an annotation&rsquo;s coordinate, in order to update its location.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Tim Ekl: The Core Data setup was fairly straightforward: I wanted Point to store latitude, longitude, and title, so I added two numeric and one string attribute to the Point entity. [&#8230;] Right off the bat, it seemed like the easiest thing to do was to make the Point instances themselves conform to MKAnnotation. They [&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":[109,31,1380,275,30,1381,474,71],"class_list":["post-17665","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-coredata","tag-ios","tag-ios-10","tag-keyvalueobserving","tag-mac","tag-macos-10-12","tag-mapkit","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17665","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=17665"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17665\/revisions"}],"predecessor-version":[{"id":17666,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17665\/revisions\/17666"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}