标题如何说明,当我打开网址时,我的共享扩展程序崩溃了
Xcode说:Thread 3: EXC_BAD_ACCESS (code=1, address=0x10)
我已经尝试过其他url方案,结果是一样的。
这是我的代码:
import UIKit
import MobileCoreServices
class ShareViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let content = extensionContext!.inputItems[0] as! NSExtensionItem
let text = kUTTypeText as String
for attachment in content.attachments as! [NSItemProvider] {
if attachment.hasItemConformingToTypeIdentifier(text) {
attachment.loadItem(forTypeIdentifier: text, options: nil, completionHandler: { (data, error) in
if error == nil {
let url = data as! URL
print(url)
print("mSwift://?\(url.absoluteString)")
let mSwift = URL(string: "mSwift://?\(url.absoluteString)")
self.extensionContext!.open(mSwift!, completionHandler: nil) // Crash here
}else {
}
})
}
}
}
}