I made A UIViewController which has a Completion handler function on it because it has to load data from a database, the code for the segue there is :
func S0000 () {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
self.showViewController(V, sender: self)
}
}
}
This throws the error :
fatal error: unexpectedly found nil while unwrapping an Optional value
How could I make it work and what am I doing wrong.
And just for information I found out that when I run it this way It works but ofcours is not finished loading when pushing to It becuase It pushes before the completion handler returns.
func S0000 () {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
self.showViewController(V, sender: self)
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
}
}
}
Try this
V.Cv { (Con) -> Void in
NSOperationQueue.mainQueue().addOperationWithBlock {
let V = self.storyboard!.instantiateViewControllerWithIdentifier("V0003") as! V0003
self.showViewController(V, sender: self)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.