面试题答案
一键面试#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *sourcePath = @"/path/to/source/file";
NSString *destinationPath = @"/path/to/destination/file";
NSError *error;
BOOL success = [fileManager copyItemAtPath:sourcePath toPath:destinationPath error:&error];
if (success) {
NSLog(@"文件复制成功");
} else {
NSLog(@"文件复制失败: %@", error);
}
}
return 0;
}