New to Swift, this worked fine for me with Objective-C. Not sure if this is a syntax issue or if I have my project set up incorrectly.
First of all, this is the error that I'm seeing (on line 5 of JobsViewController, the line that starts with self.tableView.registerClass):
Cannot invoke 'registerClass' with an argument list of type '(UITableViewCell.Type, forCellReuseIdentifier: String)'
JobsViewController
class JobsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
}
}
Google hasn't been very helpful, would appreciate some help!
Works fine in Swift 3
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
var cell : UITableViewCell = UITableViewCell()
feedTableView.registerClass(cell.classForCoder, forCellReuseIdentifier: "cellidentifier")
Try with above lines of code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With