Swift - 导入自定义文件
Swift - Importing Custom File
我正在尝试使用下面的教程在我的应用程序中导入和打开自定义文件
https://chariotsolutions.com/blog/post/importing-data-via-custom-file-types-in/
这是我的信息 plist 的样子
当我拖动扩展名为“.AMarkUp”的文件时,应用程序崩溃了
2019-03-11 11:28:37.661461+1100 Project[15404:836338] * Assertion
failure in -[UIApplication _applicationOpenURLAction:payload:origin:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIApplication.m:6851
2019-03-11 11:28:37.682291+1100 Project[15404:836338] * Terminating
app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Application has LSSupportsOpeningDocumentsInPlace key, but
doesn't implement application:openURL:options: on delegate
'
如何解决这个问题 "implement application:openURL:options: on delegate"?
感谢帮助
您需要在 AppDelegate.swift 文件中实现指定的 UIApplicationDelegate
方法。
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
// handle the file here
return true // or false based on whether you were successful or not
}
我正在尝试使用下面的教程在我的应用程序中导入和打开自定义文件
https://chariotsolutions.com/blog/post/importing-data-via-custom-file-types-in/
这是我的信息 plist 的样子
当我拖动扩展名为“.AMarkUp”的文件时,应用程序崩溃了
2019-03-11 11:28:37.661461+1100 Project[15404:836338] * Assertion failure in -[UIApplication _applicationOpenURLAction:payload:origin:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIApplication.m:6851 2019-03-11 11:28:37.682291+1100 Project[15404:836338] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application has LSSupportsOpeningDocumentsInPlace key, but doesn't implement application:openURL:options: on delegate '
如何解决这个问题 "implement application:openURL:options: on delegate"?
感谢帮助
您需要在 AppDelegate.swift 文件中实现指定的 UIApplicationDelegate
方法。
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
// handle the file here
return true // or false based on whether you were successful or not
}