ios6 - How to set iCloud Root in iPhone? -
here created local root document storage want implement icloud.so need create icloud root , check if icloud available or not. if possible create method. here added local root method code
- (nsurl *)localroot { if (_localroot != nil) { homecoming _localroot; } nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *artdirectorypath = [documentsdirectory stringbyappendingpathcomponent:@"/me"]; _localroot=[[nsurl alloc]initfileurlwithpath:artdirectorypath]; homecoming _localroot; }
you find icloud "root" directory using:
nsurl *url = [[nsfilemanager defaultmanager] urlforubiquitycontaineridentifier:nil];
if have 1 ubiquity container app, can pass nil
argument, otherwise must pass container identifier.
you can utilize check if icloud available app-- if returns nil
, can't utilize icloud. it's not best way check availability though, because can block while. quick, non-blocking check, utilize this:
id token = [[nsfilemanager defaultmanager] ubiquityidentitytoken];
and sure observe nsubiquityidentitydidchangenotification
in case availability changes.
however: near plenty start using icloud documents. can't read/write files in directory , have icloud right thing. @ absolute minimum you'll need:
nsmetadataquery
find documents exist on cloud server not downloaded locally. -[nsfilemanager startdownloadingubiquitousitematurl:error:]
tell icloud begin downloading documents you've found metadata query. coordinated access via nsfilecoordinator
, , notifications of changes via nsfilepresenter
. apple has lot of documentation, , videos wwdc help this.
iphone ios6 icloud
No comments:
Post a Comment