user10813210
user10813210

Reputation:

Type of expression is ambiguous without more context: .UIApplication.willResignActiveNotification

I am getting

Type of expression is ambiguous without more context

on the following lines:

 NotificationCenter.default.addObserver(self, selector: #selector(willResignActive), name: .UIApplication.willResignActiveNotification , object: nil)
 NotificationCenter.default.addObserver(self, selector: #selector(openedAgain), name: .UIApplication.didBecomeActiveNotification, object: nil)

What is the correct syntax?

Upvotes: 3

Views: 657

Answers (1)

Gustavo Vollbrecht
Gustavo Vollbrecht

Reputation: 3256

remove the . on UIApplication.willResignActiveNotification.

Your line should look like this:

NotificationCenter.default.addObserver(self, selector: #selector(willResignActive), name: UIApplication.willResignActiveNotification , object: nil)

Upvotes: 9

Related Questions