內部FUNC我有一個配置文件類和設置類使用從一個類到另一個類中迅速
型材類包含一個內部功能
class Profile: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
internal func profileSelectFromGallery(sender: Profile){
let myPickerController = UIImagePickerController()
myPickerController.delegate = sender;
myPickerController.sourceType =
UIImagePickerControllerSourceType.PhotoLibrary
sender.presentViewController(myPickerController, animated:true, completion: nil)
}
}
我想在設置類中使用profileSelectFromGallery,我有兩次嘗試下面
class SettingsVC: UITableViewController {
// I will call this private function on a click events
private func selectFromGallery(){
// let profile = Profile()
// profile.profileSelectFromGallery(self)
Profile.profileSelectFromGallery(self)
}
}
上述碼結果到Cannot convert value of type 'SettingsVC' to expected argument type 'Profile'
因爲profileSelectFromGallery
需要一個類的參數so 我想要做的是更改發件人,以便我可以使用它從我的任何課程,而不僅僅是我的Profile類。
我的問題是我怎麼能將發件人更改爲類似於任何類的東西,以便我可以將它用作deletegat myPickerController.delegate = sender;' –
用鏈接t應該讓你開始。 –