0

I'm trying to present a UIViewController like this:

let autocompleteVC = GMSAutocompleteViewController()
autocompleteVC.delegate = self
self.present(autocompleteVC, animated: true, completion: nil)

The VC is shown for a second and then the app crashes, Xcode breakpoints on a non-relevant line (self.buttonsScrollView!.frame.origin.y = (self.window?.frame.size.height)! - self.bounds.size.height) in another class and if delete this line I get an fatal error: unexpectedly found nil while unwrapping an Optional value error.

*The question isn't what does fatal error: unexpectedly found nil while unwrapping an Optional value means - the question is why does it crashes when I'm using the present method.

Any idea why does this happen?

Thank you!

FS.O6
  • 1,394
  • 2
  • 20
  • 42
  • @dfd It's a `Google Places SDK` class. But I've also checked it with a regular `UIViewController()` and it was the same – FS.O6 Apr 10 '17 at 16:00
  • @FS.O6 what about buttonsScrollView ? why you force unripe ? – Nazmul Hasan Apr 10 '17 at 16:04
  • @NazmulHasan It's not relevant. It happens when I put `?` as well and even when I delete that line – FS.O6 Apr 10 '17 at 16:06
  • @rmaddy this isn't a duplicate of `what does fatal error: unexpectedly found nil while unwrapping an Optional value means` - the question is why does it crashes when I'm using the present method. – FS.O6 Apr 10 '17 at 16:10
  • 1
    It's crashing because you are force unwrapping an optional somewhere. That is your issue. The duplicate clearly explains what that error means and various ways to fix it. – rmaddy Apr 10 '17 at 16:11
  • @rmaddy it's not happens because I'm unwrapping an optional value. It's happening with EVERY ViewController. – FS.O6 Apr 10 '17 at 16:14
  • Then you need to fix the forced unwrapping issue in all of your view controllers. – rmaddy Apr 10 '17 at 16:28

0 Answers0