ios - Could not cast value of type 'UITableViewCell' to '(AppName).(CustomCellName)' -
i'm trying create custom table view cell using xcode 6.3 swift 1.2. reason in cellforrowatindexpath method, can't seem set cell variable. code compile, when line of code hits:
var cell:messagecell = tableview.dequeuereusablecellwithidentifier("messagecell") as! messagecell
i error: not cast value of type 'uitableviewcell' (0x1112f5a18) 'campusexchange.messagecell' (0x10e8318f0).
here's full method: (i'm using parse if you're wondering how i'm setting 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 might have. can't seem work.
there few things can check this:
see if table linked class,
@iboutlet weak var tableview: uitableview!
register custom table view cell:
self.tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell")
note use "uitableviewcell" , identifier "cell" if custom cell has different class , id.dequeue cell in cellforrowatindexpath:
let cell: messagecell = self.tableview.dequeuereusablecellwithidentifier("messagecell") as! messagecell
use correct cell identifier.