On Apr 8, 2010, at 12:29 PM, Bill Bumgarner wrote:

> 
> On Apr 8, 2010, at 10:21 AM, Patrick M. Rutkowski wrote:
> 
>> Agreed, but there's always the danger the +array method, which might
>> actually be implemented in NSArray.m, will not properly initialize the
>> more specific NSMutableArray object.
>> 
>> Of course, in this specific case that's the case, but it might be the
>> case with other class hierarchies.
>> 
>> But, nonetheless I'm troubled that nobody in this thread has
>> acknowledged that yet :-o
> 
> Because, in practice, that doesn't generally happen. 
> 
> Across the system supplied frameworks, classes generally have designated 
> initializers and those initializers are inherited properly.  The convenience 
> creation methods -- factory methods, if you will -- are dead simple stupid, 
> generally doing the equivalent of '[[[self alloc] init*] autorelease]' where 
> the init part calls the designated initializer.

There is a problem with "things that look like convenience creation methods but 
aren't" - most notably +[NSParagraphStyle defaultParagraphStyle].  You might 
expect:

NSMutableParagraphStyle *ps = [NSMutableParagraphStyle defaultParagraphStyle];
[ps setAlignment: NSCenterTextAlignement];

to work.  It doesn't (since ps is actually an immutable NSParagraphStyle).

The major clue that is isn't a convenience creation method being found in the 
declaration:

- (NSParagraphStyle *) defaultParagraphStyle;

instead of:

- (id) defaultParagraphStyle;


Glenn Andreas                      [email protected] 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

_______________________________________________

Cocoa-dev mailing list ([email protected])

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]

Reply via email to