What will happen if I added an observer multiple times without removing it?
func registerForNotifications()
{
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(foregroundNotification(_:)), name: UIApplicationWillEnterForegroundNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(backgroundNotification(_:)), name: UIApplicationWillResignActiveNotification, object: nil)
}
registerForNotifications()
will be called in viewWillApppear
.