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
Post a Comment