後點擊了(PDF文件)使用此代碼開放:的iOS - 打開後複製的文件在我的應用
-(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;
}
我想將文件複製到我的應用程序,但我有此錯誤:
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?
這與Xcode無關。 – 2013-08-18 18:52:39