Я пытаюсь создать простой tableView программно с помощью swift, поэтому я написал этот код на "AppDelegate.swift":
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var tvc :TableViewController = TableViewController(style: UITableViewStyle.Plain)
self.window!.rootViewController = tvc
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}
В основном я добавил создание TableViewController и добавил его в окно. И это код TableViewController:
class TableViewController: UITableViewController {
init(style: UITableViewStyle) {
super.init(style: style)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// #pragma mark - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
return 1
}
override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as UITableViewCell
cell.textLabel.text = "Hello World"
return cell
}
}
Итак, когда я пытаюсь запустить код, я получаю это сообщение:
Xcode6Projects/TableSwift/TableSwift/TableViewController.swift: 12: 12: фатальная ошибка: использование нереализованного инициализатора 'init (nibName: bundle:)' для класса 'TableSwift.TableViewController'
Ошибка возникает, когда компилятор выполняет
super.init(стиль: стиль)
Любые мысли?