Bound value in a conditional binding must be of Optional type [IOS - SWIFT] -


i trying make to-do list app in xcode using swift, , encounter error writing 1 of function methods on "if let path = indexpath {" line says "bound value in conditional binding must of optional type".

func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! uitableviewcell     if let path = indexpath {                     let currentstring  = datasource[path.section][path.row]         cell.textlabel?.text = currentstring                 }             return cell } 

func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! uitableviewcell         cell.textlabel?.text = datasource[indexpath.section][indexpath.row]         return cell } 

use code because think previous idea not good.

you don't need conditional binding here suggested leo.


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

android - Linear layout children not scrolling -

javascript - Create websocket without connecting -