我目前正在尝试使用xCode 6.3 swift 1.2创建自定义表格视图单元格.出于某种原因,在cellforRowAtIndexPath方法中,我似乎无法设置我的单元格变量.代码将编译,但是当这行代码命中时:
var cell:MessageCell = tableView.dequeueReusableCellWithIdentifier("messageCell") as! MessageCell
Run Code Online (Sandbox Code Playgroud)
我收到此错误:无法将'UITableViewCell'(0x1112f5a18)类型的值转换为'CampusExchange.MessageCell'(0x10e8318f0).
这是我的完整方法:(如果你想知道我是如何设置消息,我正在使用Parse)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:MessageCell = tableView.dequeueReusableCellWithIdentifier("messageCell") as! MessageCell
let message = messagesArray[indexPath.row]["Message"] as? String
cell.messageOutlet.text = message
return cell
}
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助.我似乎无法让这个工作.