Monday 15 March 2010

objective c - iCloud Core Data IOS8 Path is outside of any CloudDocs Container -



objective c - iCloud Core Data IOS8 Path is outside of any CloudDocs Container -

my icloud core info app running great on ios7 , ready launch. when test on ios 8 next error , can't seem prepare when trying upload info icloud.

i suspect problem related how getting document directory , changes in doc directory ios8 can't figure out..

014-10-12 15:14:17.862 xxxxxxx [4662:236693] __45-[pfubiquityfilepresenter processpendingurls]_block_invoke(439): coredata: ubiquity: librarian returned serious error starting downloads error domain=brclouddocserrordomain code=6 "the operation couldn’t completed. (brclouddocserrordomain error 6 - path outside of clouddocs container, never sync)" userinfo=0x7f8b1a525f60 {nsdescription=path outside of clouddocs container, never sync, nsfilepath=/users/garyrea/library/developer/coresimulator/devices/9aadfe8e-5ecc-4969-9418-57da45b747c9/data/containers/data/application/ad2e5e62-7295-4371-a08d-1790e8fccd96/documents/coredataubiquitysupport/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/5b8bfa36-1aca-4966-b7ed-a7344d36acf1/container/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/2trlqdmqvpj~wlefilvjwtqfruj8yincd84kw_xiw4a=/f0cf5f29-d437-4728-b0a2-c5bb90bbc239.1.cdt} userinfo { nsdescription = "path outside of clouddocs container, never sync"; nsfilepath = "/users/garyrea/library/developer/coresimulator/devices/9aadfe8e-5ecc-4969-9418-57da45b747c9/data/containers/data/application/ad2e5e62-7295-4371-a08d-1790e8fccd96/documents/coredataubiquitysupport/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/5b8bfa36-1aca-4966-b7ed-a7344d36acf1/container/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/2trlqdmqvpj~wlefilvjwtqfruj8yincd84kw_xiw4a=/f0cf5f29-d437-4728-b0a2-c5bb90bbc239.1.cdt"; } these urls: ( "file:///users/garyrea/library/developer/coresimulator/devices/9aadfe8e-5ecc-4969-9418-57da45b747c9/data/containers/data/application/ad2e5e62-7295-4371-a08d-1790e8fccd96/documents/coredataubiquitysupport/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/5b8bfa36-1aca-4966-b7ed-a7344d36acf1/container/nobody~sima28745a4-a67f-598c-9260-f9ac36609ecf/icloud/2trlqdmqvpj~wlefilvjwtqfruj8yincd84kw_xiw4a=/f0cf5f29-d437-4728-b0a2-c5bb90bbc239.1.cdt" )

my app delegate extension code create persistent store follows. have seed database first time installation.

- (nspersistentstorecoordinator *)createpersistentstorecoordinator{ nspersistentstorecoordinator *persistentstorecoordinator = nil; nsmanagedobjectmodel *managedobjectmodel = [self createmanagedobjectmodel]; persistentstorecoordinator = [[nspersistentstorecoordinator alloc]initwithmanagedobjectmodel:managedobjectmodel]; nsurl *storeurl = [[self applicationdocumentsdirectory] urlbyappendingpathcomponent:@ "coredata.sqlite"]; if (![[nsfilemanager defaultmanager]fileexistsatpath:[storeurl path]]){ nsurl *preloadurl=[nsurl fileurlwithpath:[[nsbundle mainbundle]pathforresource:@"seeddatabase" oftype:@ "sqlite"]]; nserror *error=nil; if (![[nsfilemanager defaultmanager] copyitematurl:preloadurl tourl:storeurl error:&error]){ nslog(@ "file couldnt save"); } } nsubiquitouskeyvaluestore *kvstore=[nsubiquitouskeyvaluestore defaultstore]; if (![kvstore boolforkey:@"seeded_data"]){ nslog (@ "in new database"); nsurl *seedstoreurl=[nsurl fileurlwithpath:[[nsbundle mainbundle]pathforresource:@"seeddatabase" oftype:@ "sqlite"]]; nserror *seedstoreerrpr; nsdictionary *seedstoreoptions=@{nsreadonlypersistentstoreoption: @yes}; nspersistentstore *seedstore=[persistentstorecoordinator addpersistentstorewithtype:nssqlitestoretype configuration:nil url:seedstoreurl options:seedstoreoptions error:&seedstoreerrpr]; nsdictionary *icloudoptions =@{nspersistentstoreubiquitouscontentnamekey: @"icloud", nsmigratepersistentstoresautomaticallyoption:@yes, nsinfermappingmodelautomaticallyoption:@yes }; nsoperationqueue *queue=[[nsoperationqueue alloc] init]; [queue addoperationwithblock:^{ nserror *error; [persistentstorecoordinator migratepersistentstore:seedstore tourl:storeurl options:icloudoptions withtype:nssqlitestoretype error:&error]; nslog(@ "persistant store migrated"); [kvstore setbool:yes forkey:@ "seeded_data"]; // [self checkforduplicates]; }]; }else{ nserror *error; nsdictionary *storeoptions =@{nspersistentstoreubiquitouscontentnamekey: @ "icloud" }; if (![persistentstorecoordinator addpersistentstorewithtype:nssqlitestoretype configuration:nil url:storeurl options:storeoptions error:&error]) { nslog(@ "unresolved error %@, %@", error, [error userinfo]); abort(); } } homecoming persistentstorecoordinator; } - (nsurl *)applicationdocumentsdirectory{ homecoming [[[nsfilemanager defaultmanager] urlsfordirectory:nsdocumentdirectory indomains:nsuserdomainmask] lastobject]; }

i able resolve error specifying icloud drive directory (same name 1 on developer.apple.com interface).

-(nsurl *)clouddirectory { nsfilemanager *filemanager=[nsfilemanager defaultmanager]; nsstring *teamid=@"icloud"; nsstring *bundleid=[[nsbundle mainbundle]bundleidentifier]; nsstring *cloudroot=[nsstring stringwithformat:@"%@.%@",teamid,bundleid]; nsurl *cloudrooturl=[filemanager urlforubiquitycontaineridentifier:cloudroot]; nslog (@"cloudrooturl=%@",cloudrooturl); homecoming cloudrooturl; }

and including in icloudoptions dictionary nspersistentstoreubiquitouscontenturlkey

nsdictionary *storeoptions =@{nspersistentstoreubiquitouscontentnamekey: @"icloud", nspersistentstoreubiquitouscontenturlkey:[self clouddirectory], };

i getting unusual errors removed app devices, deleted icloud drive file , re ran on actual device , worked fine. not sure if runs on ios7 since specified nspersistentstoreubiquitouscontenturlkey pretty confident should fine.

objective-c core-data ios8 icloud

No comments:

Post a Comment