[英]How to NSFileHandle a file got from another app
I'm currently trying to implement the opening file from another app. 我目前正在尝试从另一个应用程序实施打开文件。 When I got to a third party app (like documents) and opening a file with my app, I can't seems to be able to open it with NSFileHandle. 当我进入第三方应用程序(如文档)并使用我的应用程序打开文件时,似乎无法使用NSFileHandle打开它。
After the AppDelegates method is called : 在调用AppDelegates方法之后:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
I get an url like this : 我得到这样的网址:
file://localhost/private/var/mobile/Applications/E9F2998C-1ED2-4955-9681-30C518FBD1A5/Documents/Inbox/text%20source%20%C3%A0%20ID-7.docx
I have tried to remove manually file://localhost/private
in order to look like a NSBunble path, but no luck... 我试图手动删除file://localhost/private
以便看起来像NSBunble路径,但是没有运气...
Does anyone have a simple way to open with NSFileHandle an URL got from that delegate method ? 有没有人可以使用NSFileHandle打开从该委托方法获得的URL的简单方法?
To convert the file NSURL
value to an actual pathname that can be used by methods and functions that require a file path, call the path
method. 要将文件NSURL
值转换为可以由需要文件路径的方法和函数使用的实际路径名,请调用path
方法。
if ([url isFileURL]) {
NSString *filePath = [url path];
// use filePath as needed
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.