Closed shankari closed 4 years ago
ok, so there were two interrelated errors here.
NSDictionary
was returning an NSNumber instead of a long. We were comparing the incoming and stored ids with a simple ==, which failed. We need to use isEqualToNumber
instead.NSNotFound
instead. NSNotFound
is the giant number above, so when we tried to delete the entry at that index, we crashed.The fixes are pretty self-explanatory.
Testing done (on iOS 13):
add event with id 737678
delete event with id 737678
<- event is removed, no crash
delete event with id 737678
again <- event does not exist, no crash
re-add event with id 737678
delete event with id 737679
<- event is not removed, no crash
Also confirmed that add + remove does not crash on android.
Not sure on older versions. This has happened many times in testing by @tzachari and others. It happens when you call
removeEventListener
when there is already an event listener registered.Concretely, at this line
so then when we call
There is a crash.