I've got a specific iOS question when accessing an outlet on a different class.
In my project I have a UItableView with custom tableViewCells which I have created using the interface builder. These cells have UItextfields on them and I need to know when a value of a certain textfield is changed. (so I can add a new empty cell with textfield, just like in your address book) I came across the following function
[UITextfield addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
The problem is that I use this function in the main class when the outlet of the textfield is in the subclass (specific tableViewCell class).
I Created an Method of the outlet so I could access it in the main class. But still is above code does not trigger the textFieldDidChange event.
Hope someone could help me with this problem. Or give me a different solution to achieve my goal (creating an new empty textfield when adding the first character to the current UITextfield).
Thnx
textFieldDidChange doesn't work. Well, I had a lot of problems with it. I don't know if it's deprecated or something. Either way you can use shouldChangeCharacterInRange almost same way as long as it's delegated correctly.
But you have to modify it a bit because the method is triggered before you actually typed something. So you have to get the new value and add it yourself.
- (BOOL) textField:(UITextField *)aTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
// Check the replacementString
return YES;
}