Lack of Initializers or Factory Methods

2008-11-03 Thread Gordon Apple
The following example is one of several I have run into recently. Inheritance is as follows: CAKeyframeAnimation: CAPropertyAnimation : CAAnimation. CAKeyframeAnimation has no explicit initializer or factory method. Dudney's book uses [CAKeyframeAnimation animation] to create an

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Jim Correia
On Nov 3, 2008, at 10:53 AM, Gordon Apple wrote: The following example is one of several I have run into recently. Inheritance is as follows: CAKeyframeAnimation: CAPropertyAnimation : CAAnimation. CAKeyframeAnimation has no explicit initializer or factory method. Dudney's book

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Charles Steinman
--- On Mon, 11/3/08, Gordon Apple [EMAIL PROTECTED] wrote: Is there a basic assumption that such factory methods are implicitly redefined for all subclasses? It's not implicitly redefined -- just inherited. One of the advantages of Objective-C's dynamic nature is that [[[self class]

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Gordon Apple
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. On 11/3/08 10:06 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Nov 3,

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Michael Ash
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.

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread graham . lee
Gordon Apple wrote on 03/11/2008 16:30:57: Is self even defined for a class object? Yes; in any method, self is (or at least starts life as) the object which received the message. If so, should case 1 (or similar) be the assumed implementation for all of Cocoa? I don't think that

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Andy Lee
On Nov 3, 2008, at 11:30 AM, Gordon Apple wrote: Is self even defined for a class object? Yes. 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. Either way,

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread j o a r
On Nov 3, 2008, at 8:37 AM, Michael Ash wrote: 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

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Gordon Apple
Ok, it looks like I should assume (at least in Cocoa) that the inherited factory methods normally return the calling class. I guess I've normally assumed that, but just never questioned it. For example, I have often used [NSMutableArray array] without even thinking about it, although I've

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Jim Correia
On Nov 3, 2008, at 11:30 AM, Gordon Apple wrote: Is self even defined for a class object? `self` is the class object when you are in a class method. 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

Re: Lack of Initializers or Factory Methods

2008-11-03 Thread Michael Ash
On Mon, Nov 3, 2008 at 11:57 AM, j o a r [EMAIL PROTECTED] wrote: On Nov 3, 2008, at 8:37 AM, Michael Ash wrote: 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;