If I send the message
[[NSFileManager defaultManager] setUbiquitous:NO
itemAtURL:url
destinationURL:iCloudURL
error:&err]
to remove an item from iCloud, it doesn't actually delete the file on the Ubiquitous Container. Is this the expected behaviour?
The method returns NO and the error object contains
Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)"
UserInfo=0x20870970 {NSURL=file://localhost/var/mobile/Applications/168EE8CD-4CDF-49BE-AD88-1DC7DD9CF25F/Documents/test.txt,
NSUnderlyingError=0x20863a00 "The operation couldn’t be completed. (LibrarianErrorDomain error 2 - Cannot disable syncing on a unsynced item.)"}
The error is pretty clear. You're trying to delete an item from iCloud that's not in iCloud. When you want to delete an item from iCloud using setUbiquitous:...
, the item URL (itemAtURL:
) should be the iCloud URL. The destination URL can be something local (but is ignored if ubiquitous is set to NO
).