{"id":7176,"date":"2013-03-18T18:49:09","date_gmt":"2013-03-18T23:49:09","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=7176"},"modified":"2013-03-18T18:53:28","modified_gmt":"2013-03-18T23:53:28","slug":"core-data-auto-migration-and-sandboxing","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/03\/18\/core-data-auto-migration-and-sandboxing\/","title":{"rendered":"Core Data Auto Migration and Sandboxing"},"content":{"rendered":"<p><a href=\"https:\/\/coderwall.com\/p\/wjaakq\">P. Taylor Goetz<\/a>:<\/p>\n<blockquote cite=\"https:\/\/coderwall.com\/p\/wjaakq\"><p>Core Data Automatic Migration for NSPersistentDocument requires saving in place, which won&rsquo;t work in a sandbox-enabled app (even with Read\/Write for user selected files).<\/p><\/blockquote>\n<p>This is like the more well-known issue with <a href=\"http:\/\/mjtsai.com\/blog\/2012\/05\/28\/core-data-document-based-application-and-sandboxing\/\">Core Data and SQLite journal files<\/a>, except that the filename suffix isn&rsquo;t predictable. Behind the scenes, Core Data tries to create a file with <tt>.migrationdestination_<\/tt> and a long hex string, and the sandbox denies it. This is not some crazy edge case&mdash;it&rsquo;s the default behavior of Cocoa&rsquo;s basic class for Core Data documents.<\/p>\n<p>A workaround is to put the database file in a package, but this is not always possible. And, in fact, <code>NSPersistentDocument<\/code> does not support packages.<\/p>","protected":false},"excerpt":{"rendered":"<p>P. Taylor Goetz: Core Data Automatic Migration for NSPersistentDocument requires saving in place, which won&rsquo;t work in a sandbox-enabled app (even with Read\/Write for user selected files). This is like the more well-known issue with Core Data and SQLite journal files, except that the filename suffix isn&rsquo;t predictable. Behind the scenes, Core Data tries to [&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":[131,69,109,30,71,53],"class_list":["post-7176","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-coredata","tag-mac","tag-programming","tag-sandboxing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7176","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=7176"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7176\/revisions"}],"predecessor-version":[{"id":7178,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7176\/revisions\/7178"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=7176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=7176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=7176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}