ios - Swift unexpectedly found nil while unwrapping an Optional value in TableView -


i know question asked many times,but not getting hint or answer those.actually new in swift.i created viewcontrollerr subclass of uitableviewcontroller.when click on table row or cell in didselectrowatindexpath method getting error fatal error: unexpectedly found nil while unwrapping optional value. trying push viewcontroller.

class sidemenucontroller: uitableviewcontroller { override func viewdidload() {         super.viewdidload()     } override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {         print("row \(indexpath.row) selected")         switch indexpath.row {         case 0:             break         case 1:             let vc = addvaluevc(nibname: "addvaluevc", bundle: nil)             //following line giving error            self.navigationcontroller!.pushviewcontroller(vc, animated: false)              break         default:             break         }      } } 

since not using uinavigationviewcontroller, should replace line

self.navigationcontroller!.pushviewcontroller(vc, animated: false) 

with this:

self.presentviewcontroller(vc, animated: false, completion: nil) 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -