在我的应用程序中,我想在 iCloud 上写文档,但我的一个 iCloud 帐户有问题,这是场景:iCloud 帐户 A,一切正常,我可以用 iPad 和 iPhone 写和读。iCloud 账户 B,同上,我可以写和读。iCloud 帐户 C,不起作用,我无法读写并给我错误。
这是一段代码:
NSURL *ubiqContainer = [[NSFileManager defaultManager]
URLForUbiquityContainerIdentifier:nil];
NSURL *ubiquitousPackage = [[ubiqContainer
URLByAppendingPathComponent:@"Documents"]
URLByAppendingPathComponent:kFILENAME];
MyDocument *mydoc = [[MyDocument alloc]
initWithFileURL:ubiquitousPackage];
self.mydoc = mydoc;
[mydoc saveToURL:[mydoc fileURL]
forSaveOperation:UIDocumentSaveForCreating
completionHandler:
^(BOOL success) {
//success is always FALSE for the Account C
}];
然后我实现了这个方法:
- (void) handleError:(NSError *)error userInteractionPermitted:(BOOL)userInteractionPermitted{
NSLog(@"error: %@", [error description]);
NSLog(@"permitted: %d", userInteractionPermitted);
}
这是日志:
error: Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x15ef24f0 {NSFileNewItemLocationKey=file:///private/var/mobile/Applications/2A1F6A00-AA50-4D44-AFA1-89D0CA747EBB/tmp/(A%20Document%20Being%20Saved%20By%20My%20App)/MyApp.esd, NSFileOriginalItemLocationKey=file:///private/var/mobile/Library/Mobile%20Documents/EAYDD3QH5Q~com~mycompany~My-App/Documents/MyApp.esd, NSUnderlyingError=0x15e3c870 "The operation couldn’t be completed. (Cocoa error 4.)", NSURL=file:///private/var/mobile/Library/Mobile%20Documents/EAYDD3QH5Q~com~mycompany~My-App/Documents/MyApp.esd}
2013-10-20 16:53:24.358 My App[222:3707] permitted: 1
我不明白为什么不能在这个帐户上工作,而在其他工作上......有什么问题?我已经重新安装了设备中存在帐户问题的所有配置文件,但不起作用,知道吗?