Why is an action method declaration necessary in the header file of a view controller?

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

Answers


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 UIButton for example), then you can remove the function from the interface file and you will not receive any error or warning

Please note that Objective-c has no pure private methods.


Need Your Help

How to set a 410 HTTP Status Code in MODX

apache http modx http-status-code-410

MODX redirects all not found pages to a 404 status code. Pages that are gone forever need to be set with a 410. Google Webmaster constantly checks for non existing pages in Crawl Errors with 404

Logging to logstash with Twisted

logging twisted logstash

I am trying to use the new logging api from twisted to send logs to a logstash server.