How to overwrite a file with NSFileManager when copying?

后端 未结 9 719
广开言路
广开言路 2020-12-02 14:13

I\'m using this method to copy a file:

[fileManager copyItemAtPath:sourcePath toPath:targetPath error:&error];

I want to overwrite a fi

9条回答
  •  无人及你
    2020-12-02 14:49

    For overwriting files, I prefer

    NSData *imgDta = UIImageJPEGRepresentation(tImg, 1.0);
    
    [imgDta writeToFile:targetPath options:NSDataWritingFileProtectionNone error:&err];
    

    Removing & copying files in loop sometimes doesn't work as intended

提交回复
热议问题