Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing always #30

Open
stephen-talari opened this issue Feb 4, 2016 · 3 comments
Open

Crashing always #30

stephen-talari opened this issue Feb 4, 2016 · 3 comments

Comments

@stephen-talari
Copy link

Always crashes at line 243
let window: UIWindow = UIApplication.sharedApplication().keyWindow! with error
fatal error: unexpectedly found nil while unwrapping an Optional value

i am calling following code in my viewController in viewDidLoad() method
SweetAlert().showAlert("Good job!", subTitle: "You clicked the button!", style: AlertStyle.Success)

screen shot 2016-02-04 at 17 54 56

`
@oguzkc
Copy link

oguzkc commented Mar 13, 2016

Same here

@oguzkc
Copy link

oguzkc commented Mar 13, 2016

@stephen-talari I solved, if you call SweetAlert in ViewDidLoad it crash, i tried in viewdidappear and a button action it worked fine. Happy coding

@acegreen
Copy link

acegreen commented Jun 4, 2016

There is no keyWindow at that point. I would add replace the following

let window: UIWindow = UIApplication.sharedApplication().keyWindow!
with:

guard let window: UIWindow = UIApplication.sharedApplication().keyWindow! else { return }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants