Question

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?

Was it helpful?

Solution

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 - unregistermethod 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top