對不起,如果問題之前已經問過..我看了沒有找到它。子類化ViewController Swift
我正在用Swift2構建IOS應用程序。我有一個很長的主類(ViewController:UIViewController)。
我想通過在另外兩個新類中繼承視圖控制器來重組我的代碼Customer:Viewcontroller和Server:ViewController。
我的目標是,這兩個分類得到執行,添加擴展功能給我viewcontroller,擴展對我沒有用,因爲我重寫的子類。
如何在應用程序啓動時執行這些類。
現在我的代碼被組織這樣的...
//ViewController handling now almost all my code
class ViewController: UIViewController,UIImagePickerControllerDelegate,MPCManagerDelegate,UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate {
///some variables
override func viewDidLoad() {
super.viewDidLoad()
////some other stuff
}
///some other functions
}
///Server subclass My goal is to print ("subclassing after view controller 's didload function
class server:ViewController {
override func viewDidLoad() {
super.viewDidLoad()
print ("loaded extern class")
}
}
在此先感謝
不清楚你在問什麼。期望的結果是什麼,實際上發生了什麼或沒有發生什麼? [還有,你的真實代碼?如果是這樣,請改變它。不要使用小寫字母來啓動類「server」的名稱。] – matt
對不起,最後的評論是一個小費錯誤..不是我真正的代碼...現在寫入我只有viewcontroller類和更多。 我通過把something = otherclasses();來訪問其他類的方法。 something.othermethods()。 我現在想要的是... ViewController有大約2000行。我想分割它的子類(或其他)以更好地控制我的代碼。 現在寫...只是爲了簡單我只想在我的主類viewDidLoad被執行後打印出「laded external class」。 –