iOS - copy file after open in my app
after clicked open in (pdf file) with this code:
-(BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if (url != nil && [url isFileURL]) {
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *filemgr;
NSError *erf;
filemgr = [NSFileManager defaultManager];
if ([filemgr copyItemAtPath:[NSString stringWithFormat:@"%@", url]
toPath:documentsDirectory error: &erf] == YES)
NSLog (@"Copy successful");
else
NSLog (@"Copy failed%@dest: %@", erf, url);
}
return YES;
}
I want copy file to my app but i have this error: Error
Domain=NSCocoaErrorDomain Code=260 "The operation couldn't be completed.
(Cocoa error 260.)" UserInfo=0x200826c0
{NSFilePath=file://localhost/private/var/mobile/Applications/*.pdf,
NSUnderlyingError=0x20082510 "The operation couldn't be completed. No such
file or directory"} Whi?
No comments:
Post a Comment