Xcode 任何对象都不能转换为UITableViewCell

Xcode 任何对象都不能转换为UITableViewCell,xcode,Xcode,我使用的是AppCoda的《Swift编程入门》一书,但我似乎无法找出这段代码的错误 import UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view

我使用的是AppCoda的《Swift编程入门》一书,但我似乎无法找出这段代码的错误

import UIKit

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

var restaurantNames = ["Cafe Deadend", "Homei", "Teakha", "CafeLoisl", "Petite Oyster", "For Kee Restaurant", "Po's Atelier", "Bourke Street Bakery", "Haigh’s Chocolate", "Palomino Espresso", "Upstate", "Traif", "Graham Avenue Meats And Deli", "Waffle & Wolf", "Five Leaves", "Cafe Lore", "Confessional", "Barrafina", "Donostia", "Royal Oak", "CASK Pub and Kitchen"]

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // Return the number of rows in the section.
    return restaurantNames.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->
        UITableViewCell {
        let cellIdentifier = "Cell"
        let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as UITableViewCell

    // Configure the cell...
        cell.textLabel.text = restaurantNames[indexPath.row]
        return cell
}

}
此行是一个“AnyObject不可转换为”UITableViewCell”

let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as UITableViewCell
我对Swift和iOS编程都是新手,所以如果有任何帮助,我将不胜感激

//MARK: Tableview
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{

    return tabledata.count


}

func tableView(tableView: UITableView!,
    cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
    let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"Cell")
    cell.textLabel?.text = tabledata[indexPath.row]

    return cell
}
我已将此代码用于tableview…您可以根据需要更改此代码。即使我是swift新手,否则我也会更正您的代码

我已将此代码用于tableview…您可以根据需要更改此代码。即使我是swift新手,否则我也会更正您的代码。

您需要更改为

另外,请确保您已使用可重用的字符串名称单元格将原型单元格添加到故事板中,您需要更改为


另外,请确保您已使用可重用的字符串名称单元格将原型单元格添加到故事板中

我可以给您一个我使用过的swift示例代码我可以给您一个我使用过的swift示例代码
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell