I am developing an app which supports viewing of document files. Problem is that I have a file whose name is in Urdu language.
When I select "Open in MyApp" option from Mail app, the file is copied into Inbox folder. I want to copy this file to some other folder. I get the file path from launchOption dictionary and pass it to copyItemAt method. Code for getting file path isNSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
NSString *urlStr = [url absoluteString];
And code for copying the file is
[[NSFileManager defaultManager] copy开发者_运维技巧ItemAtPath:urlStr toPath:destPath error:&error]
But it returns the error "No such file or directory." I have checked and the file is placed correctly in the Inbox folder with its name in Urdu language.
Kindly help. Best Regards
Usually, paths are of the form /../.../filename.extension
and file URLs are of the form file://../.../filename.extension
. When you use absoluteString
, you will get the same file://../.../filename.extension
as a string. You should message it path
instead.
NSString *urlStr = [url path];
精彩评论