Issue:
When choosing a document from iCloud the application randomly crashes, for most of the time the following code will work, but on rare occasions it will fail.
I have enabled iCloud entitlement in the app and can't seem to find the reason why it intermittently fails. Is there a check that I'm missing?
It's also hanging for a noticeable 5 or so seconds on occasions (usually in the run up to crashing)
Code:
#pragma mark - iCloud =======================================================================================================
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
BOOL fileUrlAuthozied = [url startAccessingSecurityScopedResource];
NSURL *ubiquityURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSLog(@"ubiquityURL - %@",ubiquityURL);
if(fileUrlAuthozied){
NSFileCoordinator *fileCoordinator = [[NSFileCoordinator alloc] init];
NSError *error;
[fileCoordinator coordinateReadingItemAtURL:url options:0 error:&error byAccessor:^(NSURL *newURL) {
NSData *data = [NSData dataWithContentsOfURL:newURL];
//Do something with data
selectedDocumentToUpload = [[UploadDocumentObj alloc] initWithiCloudDocument:data];
[self performSegueWithIdentifier:@"goToRename" sender:nil];
}];
[url stopAccessingSecurityScopedResource];
}else{
//Error handling
[Lib showErrorMessageWithTitle:@"Alert" message:@"E-Sign could not retrive the document!\nPlease try again." delegate:self];
}
}
Error:
2015-03-18 16:22:15.955 E-Sign[6338:1860982] *** Assertion failure in -[UIDocumentPickerViewController _commonInitWithCompletion:], /SourceCache/UIKit/UIKit-3318.93/UIDocumentPickerViewController.m:66
2015-03-18 16:22:15.960 E-Sign[6338:1860982] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application initializing document picker is missing the iCloud entitlement. Is com.apple.developer.icloud-container-identifiers set?'
Other errors:
2015-03-18 16:33:45.884 E-Sign[6357:1864309] plugin com.apple.UIKit.fileprovider.default interrupted
2015-03-18 16:33:45.885 E-Sign[6357:1864309] plugin com.apple.UIKit.fileprovider.default invalidated
Anyone come across this before?