我在应用程序中实现共享扩展时遇到问题。我正在使用 swift 3,xcode8。
override func configurationItems() -> [Any]! {
// To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
let item = SLComposeSheetConfigurationItem();
item?.title = "Test";
item?.value = "Value";
item?.tapHandler = self.show;
return [item]
}
func show() {
print("TEST");
}
当我添加该代码来配置项目时,出现异常:
2016-09-19 09:22:20.623471 ARShareExtension[10583:675495] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue setChangeObserver:]: unrecognized selector sent to instance 0x17025af40'
我不知道哪里出了问题,我正在按照苹果开发者网站中的描述进行操作。如果有人能帮助我,我将不胜感激 :) 谢谢
最佳答案
有点晚了,但如果有人对此仍有疑问,SLComposeSheetConfigurationItem()
现在由于某种原因返回一个 Optional
,但返回值应该是一组非可选项目,因此您可以执行任一操作
let item = SLComposeSheetConfigurationItem()!
或
guard let item = SLComposeSheetConfigurationItem() else { 返回 nil }
关于iOS分享扩展异常-项目配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39568256/