-1

My app creates a working file in the Application Support folder at launch, and subsequently saves that file in a user preferred folder (specified in preferences as a path). The save code is very simple:

- (void) saveFile: (NSString *) path {
    
    NSFileManager   *dm = [NSFileManager defaultManager];
    NSError         *error;
    
    if ([dm copyItemAtPath:filePath toPath:path error:&error]) {
        [dm removeItemAtPath:filePath error:&error];
    }
}

Since the move to MacOS 13.0 Ventura, the call to copyItemAtPath has failed, generating an error that looks like is:

Error Domain=NSCocoaErrorDomain Code=4 "The file “Working 20221113075654.rtf” doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/jpurlia/Library/Application Support/My App/Working 20221113075654.rtf, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=~/Documents/My App/Saved File - 20221113075729.rtf, NSFilePath=/Users/jpurlia/Library/Application Support/APBA Baseball/Working 20221113075654.rtf, NSUnderlyingError=0x6000026ff180 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

I'm not sure what's going on here, as this code has been in place for quite some time and the working file does exist in the app's folder within the Application Support folder.

Any hints what could be happening here?

Thanks!

johnpurlia
  • 113
  • 6

1 Answers1

-1

Okay, I've figured this out... The destination path can no longer be a relevant path, so ~/Documents/ has to first be expanded to the correct full path.

johnpurlia
  • 113
  • 6
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 22 '22 at 06:15