Reputation: 66320
keyboard = [[FTKeyboardHelper alloc] init];
I have a keyboard helper class, and would like to call the method keyboardShow
that is defined inside the keyboard
.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboard.keyboardShow:)
name:UIKeyboardWillShowNotification
object:nil];
However I get the error message Excepted :
Any advice?
Upvotes: 0
Views: 53
Reputation: 8664
What about
[[NSNotificationCenter defaultCenter] addObserver:keyboard
selector:@selector(keyboardShow:)
name:UIKeyboardWillShowNotification
object:nil];
I'm not sure you can "." Separate the selector, it's not a key path.
But I think that would be bad design, you should probably put that code inside your helper.
In the - init
and unregister in the - dealloc
or use a pair of - register
and - unregister
method to control this outside of the normal life cycle of your object.
But don't forget to unregister before the helper is deallocated, if not, you will crash the next time the keyboard shows up.
Upvotes: 2