Swift - Variable used within its own initial value -


func presentloggedinscreen() {     let stroyboard:uistoryboard = uistoryboard(name: "main", bundle: nil)     let logginedinvcviewcontroller:logginedinvcviewcontroller = storyboard.instantiateviewcontroller(withidentifier: "logginedinvcviewcontroller" as! logginedinvcviewcontroller,     self.present(logginedinvcviewcontroller, animated: true, completion: nil)) } 

how can avoid error?

variable used within own initial value

try this:

func presentloggedinscreen() {     let storyboard = uistoryboard(name: "main", bundle: nil)     if let logginedinvcviewcontroller = storyboard.instantiateviewcontroller(withidentifier: "logginedinvcviewcontroller") as? logginedinvcviewcontroller {         self.present(logginedinvcviewcontroller, animated: true, completion: nil)     } } 

edit: use optional binding , whats causing error , , )
intellisense of xcode doesnt work properly, try analyze problem first :)


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -