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

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -