我已經開始學習斯威夫特3幾個星期,我有一個項目,我必須轉換從斯威夫特2斯威夫特3.轉換功能與通用型SWIFT 2〜3迅速
我讀過許多文件,但我不知道如何轉換這個功能(我不知道要搜索的關鍵字)。
func pickImageFromCamera<T: UIViewController(_ delegate: T) where T: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>(){
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let myPickerController = UIImagePickerController()
myPickerController.delegate = delegate;
myPickerController.sourceType = UIImagePickerControllerSourceType.camera
delegate.present(myPickerController, animated: true, completion: nil)
}
}
它提供了以下錯誤信息:
expected '>' to complete generic argument list
更新: 這是原代碼:
func pickImageFromCamera<T: UIViewController where T: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>>(delegate: T){
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
let myPickerController = UIImagePickerController()
myPickerController.delegate = delegate;
myPickerController.sourceType = UIImagePickerControllerSourceType.Camera
delegate.presentViewController(myPickerController, animated: true, completion: nil)
}
}
有人能幫助我嗎?非常感謝。
請用您試圖使用的Swift 3代碼編輯您的問題,並清楚地指出您遇到問題的部分。 – rmaddy
'協議<>'表示法不再使用。 – matt
對不起。我已經更新了這個問題。我認爲代碼已部分轉換,但尚未完全。 – thaotruong58