-1

I was searching for a Done button for the Number Pad,then i saw this question:

How to show "Done" button on iPhone number pad

I copied Archie's answer code into mine,and i get 2 warnings in this area:

- (void)textFieldDidBeginEditing:(NSNotification *)note {
    [self updateKeyboardButtonFor:[note object]];
}


- (void)keyboardWillShow:(NSNotification *)note {
    [self updateKeyboardButtonFor:[self findFirstResponderTextField]];
}

- (void)keyboardDidShow:(NSNotification *)note {
    [self updateKeyboardButtonFor:[self findFirstResponderTextField]];
}

The warnings are:

Incompatible Objective-C types initializing 'struct NSNotification *', expected 'struct UITextField *'

How can i correct that? I tried to switch with a UITextField but it all messed up

Community
  • 1
  • 1
Phillip
  • 4,276
  • 7
  • 42
  • 74

2 Answers2

1

As BoltClock suggested, it does seem a bit strange that Archie use a delegate method's name as a notification handler. The problem might be stemming from the fact that you must be adopting the UITextFieldDelegate protocol. If you've done so, remove the line observing the notification,

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(textFieldDidBeginEditing:)
                                             name:UITextFieldTextDidBeginEditingNotification 
                                           object:nil];

and then edit make the textFieldDidBeginEditing: method while becoming the delegate of the text fields,

- (void)textFieldDidBeginEditing:(UITextField *)textField { 
    [self updateKeyboardButtonFor:textField]; 
}

Or alternatively, rename the occurrences of textFieldDidBeginEditing: with some other suitable method name

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
  • 1
    If you read the answer that the OP was referring to, it seems that post chose to use notifications instead of a text field delegate, for whatever strange reason. – BoltClock Jun 14 '11 at 16:54
0

textFieldDidBeginEditing is not a notification, it is a delegate method. The expected signature is - (void)textFieldDidBeginEditing:(UITextField *)aTextField

Joshua Weinberg
  • 28,598
  • 2
  • 97
  • 90