objective c - Error in get file from iCloud in ios -
hi in app have file icloud.. enable icloud working fine in simulator.. when test in iphone, can see icloud files when choose default delegate calls can't data url..
- (void)documentpicker:(uidocumentpickerviewcontroller *)controller didpickdocumentaturl:(nsurl *)url { nsdata *pdfdata = [[nsdata alloc] initwithcontentsofurl:url]; }
always getting pdfdata
nil. log error
error domain=nscocoaerrordomain code=257 "the operation couldn’t completed. (cocoa error 257.)" userinfo=0x17029810 {nsfilepath=/private/var/mobile/library/mobile documents/com~apple~clouddocs/download (2).jpeg, nsunderlyingerror=0x15ea9680 "the operation couldn’t completed. operation not permitted"}
i cant figure out.. can please me fix issue..
finally found answer myself.. refer link here
- (void)documentpicker:(uidocumentpickerviewcontroller *)controller didpickdocumentaturl:(nsurl *)url { [url startaccessingsecurityscopedresource]; __block nsdata *pdfdata = nil; nsfilecoordinator *coordinator = [[nsfilecoordinator alloc] init]; __block nserror *error; [coordinator coordinatereadingitematurl:url options:0 error:&error byaccessor:^(nsurl *newurl) { pdfdata = [nsdata datawithcontentsofurl:newurl]; }]; [url stopaccessingsecurityscopedresource]; }
Comments
Post a Comment