gmertk / GMStepper

A stepper with a sliding label in the middle.
https://github.com/gmertk/GMStepper
MIT License
923 stars 114 forks source link

reset() causing crash #39

Open Michaelcraun opened 6 years ago

Michaelcraun commented 6 years ago
func setup() {
    addSubview(leftButton)
    addSubview(rightButton)
    addSubview(label)

    backgroundColor = buttonsBackgroundColor
    layer.cornerRadius = cornerRadius
    clipsToBounds = true

    //Commented this line out
    NotificationCenter.default.addObserver(self, selector: #selector(GMStepper.reset), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
}

Whenever the applicationWillResignActive AppDelegate function was being called, the reset() function would cause a 'found nil while unwrapping an optional value' error. Not sure why the steppers need to be reset when the application resigns, honestly. I commented the observer out and it seems to work fine. If I'm wrong in this, or there's a better way to fix this error, please do inform me. Thanks!