objectiveccoder001
objectiveccoder001

Reputation: 3031

textDidEndEditing: Objective c example

So I know you have to put this in the .h file:

- (void)textDidEndEditing:(NSNotification *)aNotification

BUT what do I call in the .m file?? How do I show that text is done editing in one of several NSTextFields?

I looked around on the internet, but it seems pretty vague on how to use it correctly.

Any ideas? Elijah

Upvotes: 0

Views: 2442

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 72961

Take a look at UITextFieldDelegate. It will give you the method callbacks you want, such as textfieldDidEndEditing. It should pass the text field which you can then identify by object comparison or tag value.

UPDATE

Code sample for the delegate callback. Be sure to add UITextFieldDelegate to your .h file. Also specific your textField's delegate property, textField.delegate = self in your code or in IB.

- (void)textFieldDidEndEditing:(UITextField *)textField {
  if (textField.returnKeyType == UIReturnKeyDone) {
    // the textfield with the Done return key is what I care about
    self.value2 = [textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  }
}

Upvotes: 2

Related Questions