I'm currently trying to create a custom table view cell using xCode 6.3 swift 1.2. For some reason in the cellforRowAtIndexPath method, I just can't seem to set up my cell variable. The code will compile, but then when this line of code hits:
var cell:MessageCell = tableView.dequeueReusableCellWithIdentifier("messageCell") as! MessageCell
I get this Error: Could not cast value of type 'UITableViewCell' (0x1112f5a18) to 'CampusExchange.MessageCell' (0x10e8318f0).
Here's my full method: (I'm using Parse if you're wondering about how I'm setting the message)
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
}
thanks for any help you might have. I just can't seem to get this to work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…