Swift3.0專案升級到4.2遇到問題

ZY_FlyWay發表於2019-03-26
  1. Overriding non-@objc declarations from extensions is not supported

    原因: 不支援從擴充套件中覆蓋non-@objc宣告
    解決:將方法寫到主類裡

  2. Cannot subscript a value of type ‘[String : Any]’ with an index of type ‘UIImagePickerController.InfoKey’

    最初程式碼:

     var image:UIImage? = info[UIImagePickerControllerEditedImage] as? UIImage
    

    修改:

     var image:UIImage? = info[UIImagePickerController.InfoKey.editedImage.rawValue] as? UIImage
    
  3. ‘…<’ is unavailable: Any String view index conversion can fail in Swift 4; please unwrap the optional indices

    原因: 可選值進行對比
    解決: 解包

  4. Swift4.0沒有initialize方法

    解決:定義一個靜態方法,在app啟動的時候呼叫。

待續。。

相關文章