• 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 morphs itself into an NSArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: NSMutableArray morphs itself into an NSArray?
      • From: Dustin Voss <email@hidden>
References: 
 >NSMutableArray morphs itself into an NSArray? (From: Jerry Krinock <email@hidden>)
 >Re: NSMutableArray morphs itself into an NSArray? (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: Calling tableView:setObjectValue directly...
  • Next by Date: Plist
  • Previous by thread: RE: NSMutableArray morphs itself into an NSArray?
  • Next by thread: Re: NSMutableArray morphs itself into an NSArray?
  • Index(es):
    • Date
    • Thread