Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we not declare methods in the header files?

I am watching the Stanford University iPad and iPhone application Developments course video. The instructor says in the video we can control-drag an UI object to the implementation files to create an action. But in this way the method will not declare in the header file. Does this mean it is ok to implement methods in the .m file but not declare in the .h file?

like image 279
user1146115 Avatar asked Jan 12 '12 17:01

user1146115


1 Answers

Depends on how you define "ok" :-)

Objective-C uses dynamic method lookup and does not really enforce access ("private", "public", etc.) specifiers. So you don't need to declare any method in a header file.

However you will end up fighting the compiler as it does do a fair amount of type-checking unless you persuade it not to, and you'll lose by doing so.

like image 132
CRD Avatar answered Sep 30 '22 18:09

CRD