user1107173
user1107173

Reputation: 10764

iOS: IBAction/Private methods -- why declare in .m under @interface?

What's the purpose for declaring IBActions or private methods in .m file under @interface?

Xcode seems to compile fine if I put the methods anywhere in .m file without the declaration.

Upvotes: 2

Views: 439

Answers (1)

justin
justin

Reputation: 104698

More recent versions of Clang parse a little more. The compiler no longer needs to see the method declaration before use within an @implementation in this case because it knows the @implementation will close in the same translation (using @end). So it's just there for your convenience, but it's still quite recent and a lot of code was written before it was introduced.

Thus, the declaration is no longer necessary. It's of course still valid, so you can add it if you must support older toolchains or if you prefer to have its declaration in the @interface ().

Upvotes: 7

Related Questions