I am trying to get the NSData from a file path but I keep getting an error that the file couldn't be opened. Any ideas how to get the path so I can get the NSData.
for (int t = 0; t < [self.myarray count]; t++) {
NSURL *url1 = [NSURL fileURLWithPath:[self.myarray objectAtIndex:t]];
NSLog (@"url1: %@", url1);
NSError* error = nil;
NSString *filePath = [url1 path];
NSData* data = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&error];
if (error) {
NSLog(@"Data Error: %@", [error localizedDescription]);
} else {
NSLog(@"Data is: %@", data);
}
}
Here's the error log
url1: file:///var/mobile/Containers/Data/Application/85E795CA-B31D-4BD7-A777-DE7B392D6762/Documents/pImw.mp4
Data Error: The file “pImw.mp4” couldn’t be opened because there is no such file.