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:

  1. see if table linked class, @iboutlet weak var tableview: uitableview!

  2. register custom table view cell: self.tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell") note use "uitableviewcell" , identifier "cell" if custom cell has different class , id.

  3. dequeue cell in cellforrowatindexpath: let cell: messagecell = self.tableview.dequeuereusablecellwithidentifier("messagecell") as! messagecell use correct cell identifier.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -