BAD EX when you leave a view and return to it and open keyboard
This has been mentioned and closed as a previous issue but still seems to remain. Best I can tell is when removing observers there's a nil instance of the Done button retained with an observer on it, so likely a retain / leak here.
I think you've done a great job and I'd really like to use this, but right now it's unusable due to this error.
iOS 7.1
@doctordbx @SunilSpaceo i'm using this lib in production, any ideas on a fix?
@doctordbx @SunilSpaceo I think the KVOBlock library you are using has an update for this https://github.com/iMartinKiss/Block-KVO/commit/f4e5450769f8c111b55fe18156a82c2938376d2a I'm gonna try this myself and see if it fixes my crashes
@hamin Let me know how you get on please.
@doctordbx @SunilSpaceo so I figured it out. It was an issue with that KVOBlock library. I was able to reproduce this bug very consistently:
- Have Two fields, one UITextField and one SKDigitField
- Tap on SKDigitField first
- Dismiss your view controller
- Launch transition to same view controller again
- Tap on SKDigitField or the other UITextField
- You get a BAD EX crash
Using the Zombies template in Xcode Instruments I noticed that there was a Zombie (object wasn't dealloced and was being sent a message).
The culprit is actually iMartinKiss's KVOBlock library.
From what I can tell SKInput is only using that library for one method, the removeAllObservations method.
This is actually not necessary and I don't quite see the point of using that lib for this class especially since there is no direct KVO manipulation going on. SKInput is subscribing to events via NSNotificationCenter.
My solution:
- Comment out all occurences of removeAllObservations ( I found two [doneButton removeAllObservations] )
- Add a dealloc method to properly remove observations
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Essentially I think you can remove KVOBlock library completely from SKInput since you're not really using any block handlers for direct KVO handling at all @SunilSpaceo
This solved my crashes :)