This time I'm including a few pictures to help explain the issue I'm having. The app I am creating uses multiple views and multiple text fields that use a custom number pad with a view added for a decimal point.
If I input a number with a decimal point once it works great, but if I click to another view and then go back to that text field to edit it with a different number the decimal point is then added twice. (see gif files attached)
The part of the code in the view controller that adds the decimal is:
This time I'm including a few pictures to help explain the issue I'm having. The app I am creating uses multiple views and multiple text fields that use a custom number pad with a view added for a decimal point.
If I input a number with a decimal point once it works great, but if I click to another view and then go back to that text field to edit it with a different number the decimal point is then added twice. (see gif files attached)
The part of the code in the view controller that adds the decimal is:
I can post the rest of the code in the view controller and appDelegate if anyone thinks it will help.
Does anyone have any ideas? Let me know if I can post something else to clarify the question. I really appreciate anyone's help!
It's impossible to tell based on what you've posted. It sounds like your addDecimal function may be called once more than you expect but, again, given what little you've posted, no one here can determine anything.
OK, let me first confess that I'm not familiar with some of the classes you're using in this code, but I get the gist of what you're doing here.
Having said that, I suspect that there may be a path through this code in which you're registering multiple observers for the same "DecimalPressed" event, and that's what is causing multiple decimal points to be added to your string. I don't see anything in the NSNotificationCenter docs indicating that registration of multiple identical observers is not allowed, so this theory is at least plausible. I would add breakpoints to the lines that add the observers to the notification center and see if you can find a case where this happens.
I finally figured out the issue. I did have too many observers or rather nothing to stop the observing. I had to separate the notification observers for each text field and then remove the observer as soon as the text editing stopped: