user979331
user979331

Reputation: 11911

swift - Method does not override any method from its superclass & 'UITableView' does not have a member named 'viewDidLoad'

I am very new to swift and when I say new, I mean I just started this morning, I am having an issue I tried googling for but can't seem to find a solution.

I have this swift file:

import UIKit

class ProntoController: UITableView {

    var tableView:UITableView?
    var items = NSMutableArray()

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    func viewWillAppear(animated: Bool) {

        NSLog("Here")

        let url = "API.php"

        NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!) { data, response, error in
            NSLog("Success")
        }.resume()
    }

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.items.count;
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell

        return cell!
    }


}

My problem is with this section of code:

override func viewDidLoad() {
        super.viewDidLoad()
    }

I get these two errors:

'UITableView' does not have a member named 'viewDidLoad'
Method does not override any method from its superclass

Upvotes: 0

Views: 6464

Answers (1)

libec
libec

Reputation: 1554

You need to subclass UITableViewController, you're subclassing UITableView

Upvotes: 6

Related Questions