iCloud UIDocumentPicker间歇性崩溃并挂起 [英] iCloud UIDocumentPicker crashes intermittently and hangs

查看:392
本文介绍了iCloud UIDocumentPicker间歇性崩溃并挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

从iCloud中选择文档时,应用程序会随机崩溃,在大多数情况下,以下代码将起作用,但在极少数情况下,它将失败.

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.

我已在应用程序中启用了iCloud权利,但似乎找不到其间歇性失败的原因.有我遗失的支票吗?

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?

它有时还会挂上5秒钟左右(通常是在崩溃之前)

It's also hanging for a noticeable 5 or so seconds on occasions (usually in the run up to crashing)

代码:

#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];

}
}

错误:

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?'

其他错误:

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

有人遇到过吗?

推荐答案

我最近在Opon遇到了同样的问题:

I recently stumpled opon the same problem:

***-[UIDocumentPickerViewController _commonInitWithCompletion:]中的断言失败

*** Assertion failure in -[UIDocumentPickerViewController _commonInitWithCompletion:]

是由于缺乏应用程序功能引起的. 转到您的版本,然后选择功能-> iCloud

is caused due to lacking App-Capabilities. Go to your Build and choose Capabilities -> iCloud

通过右侧的开关激活它,然后将 iCloud文档 CloudKit 切换为开. (注意:这仅适用于付费开发者帐户)

Activate it via the switch on the right hand side and toggle iCloud Documents and CloudKit ON. (Notice: This will only work with a payed developer account)

重建->运行

还请记住:

iCloud权利仅适用于提交到App Store或Mac App Store的应用程序. (源)

iCloud entitlements are available only to apps submitted to the App Store or to the Mac App Store. (Source)

这篇关于iCloud UIDocumentPicker间歇性崩溃并挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆