class MainViewController: UIViewController {
//只要重写init方法,就必须要实现的下面三个init方法,少一个都不行
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
init(_ argc : String) {
self.init()
self.name = argc
}
private var name:String!
override func viewDidLoad() {
super.viewDidLoad()
print("姓名:\(self.name!)")
}
}
网友评论