Re: Private Method?
Re: Private Method?
- Subject: Re: Private Method?
- From: Joar Wingfors <email@hidden>
- Date: Sun, 06 Nov 2011 23:49:36 -0800
On 6 nov 2011, at 14:10, Bryan Harrison wrote:
> I'm a total tyro and hope nobody minds if I fire off the occasional incredibly elementary question.
>
> I'm reviewing some sample code and am looking at a class with a method declared in @implementation which isn't mentioned in any @interface.
>
> Is this a private method, something else entirely, or merely sloppy coding?
>
> If the former, how does this technique compare with the trick of putting an…
>
> @interface someClass ()
> - (type) somePrivateMethod;
> @end
>
> …in the implementation?
Hello Bryan,
That would be a private method, or - like Graham pointed out - an override of a method from a superclass. I guess it could also be "dead" code (not called from anywhere), but that's typically not very likely.
In OjbC you don't need to provide declarations for a method "foo" if all callers of foo can "see" the definition of foo (ie. if they are themselves defined *after* foo). The definition also serves as a declaration in such a case.
Sure you can provide private declarations in a class extension, but why would you? To avoid repetition is a virtue, and one of the more important ones at that.
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden