Uniform Type Identifier(UTI)
将第3方APP中的文件,使用自家app打开查看
实质是:将第3方的app中的文件 复制到了 自家app的doc/Inbox文件夹内
在info.plist加入
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>icon_22x29</string>
<string>icon_44x58</string>
<string>icon_64x64</string>
<string>icon_320x320</string>
</array>
<key>CFBundleTypeName</key>
<string>allFiles</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
public.data代表 自家app可以打开处理任意文件
四张不同格式的png图片 不知道用到没有
附:
apple官方info.plist中各字段含义
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
/*外部文件访问本应用,会传递参数过来*/
NSLog(@"application = %@",application);
NSLog(@"url = %@",url);
NSLog(@"sourceApplication = %@",sourceApplication);
NSLog(@"annotation = %@",annotation);
}
打印结果:
// 在自家app的doc的Inbox目录中的文件路径
url = file://localhost/private/var/mobile/Applications/10A7BAB7-A437-4DE5-8A67-342AD74956EC/Documents/Inbox/1.jpeg