{"id":12348,"date":"2015-09-23T16:10:21","date_gmt":"2015-09-23T20:10:21","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=12348"},"modified":"2015-09-23T16:10:21","modified_gmt":"2015-09-23T20:10:21","slug":"the-big-nerd-ranch-core-data-stack","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/09\/23\/the-big-nerd-ranch-core-data-stack\/","title":{"rendered":"The Big Nerd Ranch Core Data Stack"},"content":{"rendered":"<p><a href=\"https:\/\/www.bignerdranch.com\/blog\/introducing-the-big-nerd-ranch-core-data-stack\/\">Robert Edwards<\/a> notes that the Nested Managed Object Context Pattern has some cons:<\/p>\n<blockquote cite=\"https:\/\/www.bignerdranch.com\/blog\/introducing-the-big-nerd-ranch-core-data-stack\/\"><ul> <li>Slower than <a href=\"https:\/\/www.bignerdranch.com\/blog\/introducing-the-big-nerd-ranch-core-data-stack\/#shared_coordinator\">Shared Persistent Store Coordinator Pattern<\/a> when inserting large data sets<\/li> <li><code>awakeFromInsert<\/code> being called on <code>NSManagedObject<\/code> subclasses for each context in the parent chain<\/li> <li>Merge policies only apply to a context saving to a store and not to its parent context<\/li> <\/ul>\n<p>[&#8230;]<\/p>\n<p>Since saving an <code>NSManagedObjectContext<\/code> will only propagate changes up a single level to the <code>parentContext<\/code>, the Big Nerd Ranch Core Data Stack listens for save notifications and ensures that the changes get persisted all the way up the chain to your store.<\/p>\n<p>You may sometimes need to perform large import operations where the nested context performance would be the bottleneck. For that, we&rsquo;ve included a function to vend you a managed object context with its own stack <code>newBatchOperationContext(setupCallback: CoreDataStackBatchMOCCallback)<\/code>. This follows the pattern outlined in <a href=\"https:\/\/www.bignerdranch.com\/blog\/introducing-the-big-nerd-ranch-core-data-stack\/#shared_store\">Shared Store Stack Pattern<\/a>.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Robert Edwards notes that the Nested Managed Object Context Pattern has some cons: Slower than Shared Persistent Store Coordinator Pattern when inserting large data sets awakeFromInsert being called on NSManagedObject subclasses for each context in the parent chain Merge policies only apply to a context saving to a store and not to its parent context [&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,109,31,30,138,71],"class_list":["post-12348","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-coredata","tag-ios","tag-mac","tag-optimization","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12348","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=12348"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12348\/revisions"}],"predecessor-version":[{"id":12349,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12348\/revisions\/12349"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=12348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=12348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=12348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}