Table View Controller in storyboard with Class

时间:2015-10-06 08:22:31

标签: ios swift uitableview storyboard

I added a Table View Controller to my storyboard. Then i set the Class of the Table View Controller to my class SubscriptionsTableViewController: UITableViewController

Now i want to populate it with a cell i've made.

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell
return cell

This gives me Value of type SubscriptionsTableViewController has no member dequeueReusableCellWithIdentifier

How do i access the dequeueReusableCellWithIdentifier in TableViewController class? Shouldn't i be able to use self.dequeueReusableCellWithIdentifier since i've set the class in Storyboard?

1 个答案:

答案 0 :(得分:2)

dequeueReusableCellWithIdentifier is not UITableViewController method. It is UITableView method

So, you need

let cell = tableView.dequeueReusableCellWithIdentifier("subscriptionCell") as! SubscriptionsTableViewCell

Check the documentation first.

Be sure to register SubscriptionsTableViewCell as cell class of your table view.