I have a very simple code to record a file downloaded from a URL in the SandBox. The file I save it in an object NSData
but at the time of writing it with writeToFile
it does not do it. On the other hand I have another code that is practically the same as if it is written but with the proviso that the directory that I create is temporary with NSTemporaryDirectory
.
NSString *documentsDir = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"midirectorio"];
NSData *data = [NSData dataWithContentsOfURL:url];
BOOL result = [data writeToFile:documentsDir atomically:YES];
if (result) {
NSLog(@"WF OK %@",url);
} else {
NSLog(@"WF KO %@",url);
}
What am I doing wrong?