Hi I am working on an app at the moment that requires number input to be formatted as the textfield changes as well as perform a calculation. I have the text fields set up so that as the user types notifications are passed out and a calculation is performed. However what I need to do now is format the text to be in this style: €1,000,000 rather than 1000000. I have this working for the output of the calculation already but everytime I try to apply it to the input text the simulator seems to crash or at least freezes for a while. I'd imagine its a simple enough fix.
I am using this code to notify when each text field is changing:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.futureTxt];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.presentTxt];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.monthlyTxt];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.moneyTxt];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.termTxt];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:self.advancedTxt];
The above code is placed inside viewDidLoad. Each time one the textfields sends a notification it is seen by textFieldDidChange and a method called calculate is called thereafter.
I am assumuing however that the problem I am having is that I am trying to type in a text field and output data in the same text field while I type. So if the user starts to type the € should be placed in front of the textfields text, and as they insert more than 3 characters as well as € a comma should be inserted at index 2. I know the indexes etc that need to change but the app just keeps crashing each time I try to do this.
If I need to explain more then please let me know.
Conor