【发布时间】:2015-03-20 20:51:24
【问题描述】:
我有一个应用程序,它使用-(BOOL)application:openURL: 从 HTTP url 打开 PDF。
于是我去Safari,在Safari中打开PDF,然后使用[Open in "MyAPP"]
我想保存 URL,这样当用户关闭应用再打开时,PDF 可以再次打开。
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// to store
[defaults setObject:[url absoluteString] forKey:@"LastPDFURL"];
[defaults synchronize];
<...etc...>
return YES;
}
当我从 Key LastPDFURL 加载时,而不是获取:
(NSString*) @"http://www.someWebsite.com/LastPDF.pdf"
在将 pdf 导入我的应用程序后,我获得了本地 URL,例如:
(NSString*) @"file:///<..dir..>/Developer/CoreSimulator/Devices/<..deviceID..>/
data/Containers/Data/Application/<..appID..>/Documents/Inbox/LastPDF.pdf"
所以我的问题是:
是否可以在此文件导入交互中获取执行导入的源 URL?即“http://www.someWebsite.com/LastPDF.pdf”?
【问题讨论】: