2016-09-19 30 views
1

我遇到了在應用程序中實施共享擴展的麻煩。我正在使用swift 3,xcode8。iOS共享擴展異常 - 項目配置

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' 

我不知道什麼是錯的,我做它在蘋果開發者網站描述。我將不勝感激

回答

2

有點晚,但如果有人仍然有這個問題,SLComposeSheetConfigurationItem()由於某種原因現在返回Optional,但返回值應該是一個非數組 - 可選的項目,所以你可以做任何

let item = SLComposeSheetConfigurationItem()!

guard let item = SLComposeSheetConfigurationItem() else { return nil }

+0

這工作得很好:)謝謝! –