I’ve noticed that if I remove the action method declaration in the header file of a view controller, the action still works as it is implemented in the implementation file. Why is it necessary to define a method declaration in the header file of a view controller?
Thanks
so that you dont receive warnings from the compiler that the selector is not found,
In ARC environment, removing the function declaration from the .h file will result in error and not warning (
No visible @interface for 'YourClass' declares the selector 'YourMethod')However if you connect your method from xib (action for a
UIButtonfor example), then you can remove the function from the interface file and you will not receive any error or warningPlease note that Objective-c has no pure private methods.