• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSMutableArray array]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSMutableArray array]


  • Subject: Re: [NSMutableArray array]
  • From: glenn andreas <email@hidden>
  • Date: Thu, 08 Apr 2010 14:03:26 -0500

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@hidden
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@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

References: 
 >[NSMutableArray array] (From: "Patrick M. Rutkowski" <email@hidden>)
 >Re: [NSMutableArray array] (From: Dave DeLong <email@hidden>)
 >Re: [NSMutableArray array] (From: "Patrick M. Rutkowski" <email@hidden>)
 >Re: [NSMutableArray array] (From: Bill Bumgarner <email@hidden>)
 >Re: [NSMutableArray array] (From: "Patrick M. Rutkowski" <email@hidden>)
 >Re: [NSMutableArray array] (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: How does Finder determine when a file is busy being written to the disk?
  • Next by Date: Re: [NSMutableArray array]
  • Previous by thread: Re: [NSMutableArray array]
  • Next by thread: Re: [NSMutableArray array]
  • Index(es):
    • Date
    • Thread