Reputation: 413
In Java, when you override a method, you are advised (almost forced) to add the @Override
annotation. Is there a convention to mark (either in comments, or by some other mechanism) overridden methods in the Objective-C world?
Upvotes: 8
Views: 2451
Reputation: 28786
I'm not sure if Xcode does this, but the AppCode IDE from Jetbrains automatically annotates overridden methods with the little blue override badge in the margin, like so:
. . further to that (also shown), I also like to create some live templates (aka code-snippets in Xcode) to annotate overridden methods with a #pragma tag. I find that it helps to define a standard structure in this order:
and by having Live Templates/Code Snippets I can just type 'override [tab]' and the IDE will create the #pragma tag for me.
. . perhaps you could even use OCLint to check that this structure is adhered to.
Upvotes: 1
Reputation: 44886
No. All methods in Objective-C are sent via Objective-C's messaging, so all methods can be overridden. That's part of the language.
There's no convention for marking this, either. It's part of the language that it happens, and if you were to comment otherwise it'd just be confusing when you did it later, accidentally or intentionally.
Upvotes: 4
Reputation: 86701
No, not really.
It doesn't seem to matter as much, probably because of the dynamic dispatch.
Upvotes: 0