• 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: Protecting memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Protecting memory


  • Subject: Re: Protecting memory
  • From: Crispin Bennett <email@hidden>
  • Date: Wed, 25 Jul 2012 15:07:53 +1000

On 19/07/2012, at 12:08 PM, Rich Siegel wrote:

> Is it a code pattern in which you make a mutable array, populate it, and then want it to be immutable thereafter? If so, you could do something like:
>
>    NSMutableArray  *myArray = [NSMutableArray arrayWithCapacity: 0];
>    NSArray         *myConstArray = nil;
>
>    //...fill the array...
>
>    myConstArray = [NSArray arrayWithArray: myMutableArray];
>
> The result of [NSArray arrayWithArray] is an immutable NSArray, which it sounds like is what you want.

Isn't -copy (as already suggested) a simpler option? The NSCopying/NSMutableCopying protocol pair seems to be the most natural Cocoa pattern for making im/mutable copie.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Protecting memory
      • From: Jens Alfke <email@hidden>
References: 
 >Re: Protecting memory (From: Rich Siegel <email@hidden>)

  • Prev by Date: Re: Xcode SPOD after upgrade the Lion 10.7.4
  • Next by Date: Viewing PDF in Xcode
  • Previous by thread: Re: Protecting memory
  • Next by thread: Re: Protecting memory
  • Index(es):
    • Date
    • Thread