我已经开始学习斯威夫特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