• 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: safe and efficient way tp duplicate NSMutable array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: safe and efficient way tp duplicate NSMutable array


  • Subject: Re: safe and efficient way tp duplicate NSMutable array
  • From: "Shawn Erickson" <email@hidden>
  • Date: Tue, 17 Apr 2007 16:11:13 -0700

On 4/17/07, Jay <email@hidden> wrote:
Hello,
I'm using NSMutabArray to store some instance objects of customer class, I find it quite complex when try to create another identical MutableArray object instance and it is easy to get into some troubles while duplicating the array, will there be some safe ways to do it?
Thanks a lot. This may be some kind of simple questions but....

What is complex about [theMutableArray mutableCopy] or [theMutableArray copy]? Also exactly what issues are you having trouble with?

It is important to note that copies using the above are shallow
copies. In other words you get a new array instance referencing the
same set of object instance as the original array.

If you want a deep copy use [[NSMutableArray alloc]
initWithArray:sourceArray copyItems:YES] or [[NSArrray alloc]
initWithArray:sourceArray copyItems:YES] depending on what type of
array you want.

Obviously if you want a deep copy then all objects in the array have
to implement the NSCopying protocol so they can be copied fully.

-Shawn
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: safe and efficient way tp duplicate NSMutable array
      • From: "Jay" <email@hidden>
References: 
 >safe and efficient way tp duplicate NSMutable array (From: "Jay" <email@hidden>)

  • Prev by Date: Re: Document based apps & tabbed windows?
  • Next by Date: Re: silly question about build/release
  • Previous by thread: Re: safe and efficient way tp duplicate NSMutable array
  • Next by thread: Re: safe and efficient way tp duplicate NSMutable array
  • Index(es):
    • Date
    • Thread