{"id":313,"date":"2011-06-19T23:27:50","date_gmt":"2011-06-19T14:27:50","guid":{"rendered":"http:\/\/redwing.moo.jp\/cocoa\/?p=313"},"modified":"2011-06-19T23:27:50","modified_gmt":"2011-06-19T14:27:50","slug":"coredata-%e3%83%9e%e3%82%a4%e3%82%b0%e3%83%ac%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3","status":"publish","type":"post","link":"https:\/\/redwing.moo.jp\/cocoa\/archives\/313","title":{"rendered":"CoreData \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3"},"content":{"rendered":"<p>CoreData \u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u624b\u9806\u306f\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<p><strong>1. \u30e2\u30c7\u30eb\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3001\u30e2\u30c7\u30eb\u3092\u5909\u66f4\u3059\u308b<\/strong><br \/>\n<strong>2. Mapping Model \u3092\u8ffd\u52a0\u3059\u308b<\/strong><br \/>\n<strong>3. \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b<\/strong><br \/>\n&#8211; (NSPersistentStoreCoordinator *)persistentStoreCoordinator \u30e1\u30bd\u30c3\u30c9\u306b\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u6307\u5b9a\u3092\u884c\u3046\u51e6\u7406\u3092\u8ffd\u52a0\u3059\u308b<\/p>\n<pre lang=\"objc\" line=\"1\">\r\n\/**\r\n Returns the persistent store coordinator for the application.\r\n If the coordinator doesn't already exist, it is created and the application's store added to it.\r\n *\/\r\n- (NSPersistentStoreCoordinator *)persistentStoreCoordinator\r\n{\r\n    if (__persistentStoreCoordinator != nil)\r\n    {\r\n        return __persistentStoreCoordinator;\r\n    }\r\n    \r\n    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@\"CoreDataSample.sqlite\"];\r\n    \r\n    \/\/ \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u6307\u5b9a\r\n\tNSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:\r\n\t\t\t\t\t\t\t [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,\r\n\t\t\t\t\t\t\t [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];\r\n    \r\n    NSError *error = nil;\r\n    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];\r\n    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])\r\n    {\r\n\r\n<\/pre>\n<a href=\"https:\/\/twitter.com\/redwing1300?ref_src=twsrc%5Etfw\" class=\"twitter-follow-button\" data-size=\"large\" data-show-count=\"false\">Follow @redwing1300<\/a><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content --><div id=\"redwi-3351092031\" class=\"redwi- redwi-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-9652476346722993\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-9652476346722993\" \ndata-ad-slot=\"\" \ndata-ad-format=\"auto\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>CoreData \u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u624b\u9806\u306f\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3002 1. \u30e2\u30c7\u30eb\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3001\u30e2\u30c7\u30eb\u3092\u5909\u66f4\u3059\u308b 2. Mapping Model \u3092\u8ffd\u52a0\u3059\u308b 3. \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b &#8211; (NSP &hellip; <a href=\"https:\/\/redwing.moo.jp\/cocoa\/archives\/313\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-cocoa"],"_links":{"self":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/comments?post=313"}],"version-history":[{"count":7,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/posts\/313\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redwing.moo.jp\/cocoa\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}