ios - Get data contents of iCloud URL without UIDocument -
is possible contents of icloud url without having go through uidocument?
you can use following code downloding contents of icloud url without creating object of nsdocument. worked me...
-(void)loaddata:(nsmetadataquery *)query { if ([query resultcount] == 1) { nsmetadataitem *item = [query resultatindex:0]; nsurl *fromurl = [item valueforattribute:nsmetadataitemurlkey]; nsurl *tourl=[nsurl fileurlwithpath:@"path_of_file_to_store_data"]; nsfilecoordinator *coordinator = [[nsfilecoordinator alloc] initwithfilepresenter:nil]; [coordinator coordinatereadingitematurl:fromurl options:0 writingitematurl:tourl options:nsfilecoordinatorwritingforreplacing error:nil byaccessor:^(nsurl *newreadingurl, nsurl *newwritingurl) { [[nsfilemanager defaultmanager] removeitematpath:newwritingurl.path error:null]; [[nsfilemanager defaultmanager] copyitematpath:newreadingurl.path topath:newwritingurl.path error:nil]; }]; } }
Comments
Post a Comment