我正在阅读的那一章是在讲NSFileManager,作者说要创建一个名为testFile. 与testFile位于同一文件夹下main.m。我没有创建newfile. 我不能复制testFile,这是returning 2和一个NSLog说法@"couldnt copy file"。我试图将 toPath: 的论点设置为@"/Users/el/Desktop/prog/prog/newfile"
int main (int argc, char *argv[]) {
@autoreleasepool {
NSString *fName = @"/Users/el/Desktop/prog/prog/testFile";
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath: fName] == NO) {
NSLog(@"couldnt find file");
return 1;
}
if ([fm copyItemAtPath:fName toPath:@"newfile" error:NULL] == NO) {
NSLog(@"couldnt copy file");
return 2;
}