Skip to content

Need to make extension implement TableViewDelegate and TableViewDataSource #47

@brianwang9100

Description

@brianwang9100

Earlier in the tutorial in P2 you asked the students to add an extension to NotesViewController:UITableViewController:

extension NotesViewController {

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("NoteCell", forIndexPath: indexPath) as! NoteTableViewCell //1

        cell.textLabel?.text = "Hello World"

        return cell
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }

}

And then later in P11, you asked them to change the subclass of NotesViewController to UIViewController instead of UITableViewController so that you can make a tableView @IBOutlet. This means that you now have to make the extension for NotesViewController to implement TableViewDelegate and TableViewDataSource. You might want to add in your tutorial for P11 to change the extension to implement the protocols:

extension NotesViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    ...
}

Also keep in mind that the students need to remove override as well.

If you want me to put a pull request for this I can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions