1
votes

I have a custom UIStoryboardSegue that crossfades between my view controllers. For some reason, using the iPhone 5 or iPhone 5s simulator creates a nil error on this line:

let window = UIApplication.shared.keyWindow!

fatal error: unexpectedly found nil while unwrapping an Optional value

1

1 Answers

0
votes

I've solved this problem by delaying when I perform my segue. It seems that at the speed my app loads, by the time UIApplication.shared.keyWindow is required, it's not set yet. I used a timer to delay when my segue is called and it invalidates once it is ready.