You're passing an NSURL
to an API that expects a path in an NSString
. You might consider using the URL-based API:
- (BOOL)copyItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL error:(NSError **)error NS_AVAILABLE(10_6, 4_0);
Like this:
[fileManager copyItemAtURL: [[openDlg URLs] objectAtIndex:0] toURL: [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]] error:&error];
Also, I'm guessing that the file has already been copied to the bundle since your description indicates that [fileManager fileExistsAtPath:dataPath]
is returning NO
(since your NSLog is never executed.) You can either check that manually, or you can ask the NSFileManager
to delete any existing file before copying in a newly selected file.