简体   繁体   English

对成员'(_:numberOfRowsInSection :)的含糊不清的引用

[英]Ambiguous reference to member '(_:numberOfRowsInSection:)'

I'm trying to GET gists from Github and pop them in a table view, here's the entire code, Gist is a class defined elsewhere: 我正在尝试从Github中GET gist并将其弹出到表视图中,这是完整的代码, Gist是在其他地方定义的类:

var gists = [Gist]()

override func viewDidAppear(animated: Bool) {
    loadGists()
}

func loadGists() {
    GithubAPIManager.sharedInstance.fetchPublicGists() { result in
        guard result.error == nil else {
            print("Error 1")
            return
        }

        if let fetchedGists = result.value {
            self.gists = fetchedGists
        }
        self.tableView.reloadData()
        //Error here. 
    }
}

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

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell")!

    let gist = gists[indexPath.row]
    cell.textLabel?.text = gist.description
    cell.detailTextLabel?.text = gist.ownerLogin

    return cell
}

So, the problem is I didn't add an outlet of the table view to the View Controller.swift. 所以,问题是我没有在View Controller.swift中添加表视图的出口。 Just dragged the table view to the .swift file to create it. 只需将表视图拖动到.swift文件即可创建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM