私のアプリでは、iCloud でドキュメントを書きたいのですが、1 つの 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
なぜこのアカウントでは機能しないのか、他のアカウントでは機能しないのか理解できません...何が問題なのですか? アカウントに問題があるデバイスにすべてのプロファイルを再インストールしましたが、機能しません。何か考えはありますか?