I noticed that copyItemAtURL:toURL:error: and moveItemAtURL:toURL:error: methods have different behavior on iOS 14 beta 7.
For example:
Method - (BOOL)copyItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL error:(NSError * _Nullable *)error;
From Apple documentation: "If a file with the same name already exists at dstURL, this method stops the copy attempt and returns an appropriate error."
On devices with iOS 13 this method works as expected. It returns an error because the file already exists at dstURL.
But on iOS 14 it does the opposite. It copies the file without errors.
Code sample:
For example:
Method - (BOOL)copyItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL error:(NSError * _Nullable *)error;
From Apple documentation: "If a file with the same name already exists at dstURL, this method stops the copy attempt and returns an appropriate error."
On devices with iOS 13 this method works as expected. It returns an error because the file already exists at dstURL.
But on iOS 14 it does the opposite. It copies the file without errors.
Code sample:
Code Block NSData *fileContents = [@"Put this in a file" dataUsingEncoding:NSUTF8StringEncoding]; NSString *directory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSString *filePath = [directory stringByAppendingPathComponent:@"test.txt"]; NSFileManager *manager = [NSFileManager defaultManager]; [manager setDelegate:self]; [manager createFileAtPath:filePath contents:fileContents attributes:nil]; NSError *error = nil; NSURL *url = [NSURL fileURLWithPath:filePath]; BOOL result = [manager copyItemAtURL:url toURL:url error:&error];