Re: NSMutableArray morphs itself into an NSArray?
Re: NSMutableArray morphs itself into an NSArray?
- Subject: Re: NSMutableArray morphs itself into an NSArray?
- From: Shawn Erickson <email@hidden>
- Date: Mon, 8 Mar 2004 11:42:48 -0800
On Mar 8, 2004, at 10:37 AM, Dustin Voss wrote:
The convenience constructors like +array are intended for local
variables, not instance variables. To allocate an instance variable,
the pattern is:
crontabLines = [[NSMutableArray alloc] init];
The above is kind of a strange comment...
The convenience "constructors" exists, as implied, for your convenience
and you can use them any time or place that you want in your code (no
local/instance var differentiation). Depending on what you are doing
you may have to retain the return objects to get them to live longer
then the current auto release pool.
In the case of instance variables the generally accepted pattern is to
use accessor methods to set and get your instance variables (even in
init). Those methods should take care of the needed retain (or copy) /
release.
In general it is better to use what is most convenient (simple) in your
code unless it somehow leads to a performance / resource issue the
requires an alternate, potentially less convenient, solution.
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.