The following is my code and I have the newfile2 in the same directory as main.m is located(see image) but I am getting File read failed error. Where am I going wrong?
import
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSFileManager *fm;
NSData *fileData;
fm = [NSFileManager defaultManager];
//Read from the file nwefile2
fileData = [fm contentsAtPath:@"newfile2"];
if (fileData == nil) {
NSLog(@"File read failed");
return 1;
}
//Write the data to a file
if ([fm createFileAtPath:@"newfile3" contents:fileData attributes:nil] == NO) {
NSLog(@"File creation failed");
return 2;
}
NSLog(@"File copy successful");
}
return 0;
}
