On Mon, Nov 3, 2008 at 11:30 AM, Gordon Apple <[EMAIL PROTECTED]> wrote: > Is "self" even defined for a class object? If so, should case 1 (or > similar) be the assumed implementation for all of Cocoa? If not, then, > IMHO, the docs in general should specify which is is for each factory > method.
Yes, classes are objects too, and 'self' has the exact same meaning in a class method as it does in an instance method. (That meaning is, it is the receiver of the message.) If the method is declared like this then you should assume that you get a subclass: + (id)foo; And if it is declared like this then you should not assume that: + (Foo *)foo; The difference being the return type. The 'id' return type implicitly means "this will return whatever is appropriate for the receiver". (This should probably be documented better.) The 'Foo *' return type tells you only to expect a Foo, and not rely on receiving any sort of subclass. The latter form is rare in Cocoa but shows up in e.g. NSParagraphStyle. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]