• 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: Private copy not working correctly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private copy not working correctly


  • Subject: Re: Private copy not working correctly
  • From: Joe Turner <email@hidden>
  • Date: Fri, 03 Jul 2009 10:17:00 -0500

Thanks, this seems to work perfectly!

I recently read about shallow and deep copies, but didn't see the initWithDictionary:copyItems: method.

Thanks,

Joe
On Jul 2, 2009, at 6:51 PM, Adam R. Maxwell wrote:


On Jul 2, 2009, at 12:05 PM, Joe Turner wrote:

I'm trying to create a private copy of an object, but yet when the original changes, my copy changes too.
I have an array of dictionaries called spacesData. Then, when I do: NSDictionary *backup = [[spacesData objectAtIndex:index] copy]; everything is fine, and this one looks as it should. Then, when I change something in spacesData objectAtIndex:index], this private copy changes too. Doesn't "copy" create a private copy, or am I doing something wrong?

Copying a collection makes a shallow copy, so only the collection itself is copied, not the values that it contains. If you want to copy values, check out -[NSDictionary initWithDictionary:copyItems:], or CFPropertyListCreateDeepCopy().


--
Adam


_______________________________________________

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: 
 >Private copy not working correctly (From: Joe Turner <email@hidden>)
 >Re: Private copy not working correctly (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: Re: User interface validation doesn't work, right?
  • Next by Date: Re: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive
  • Previous by thread: Re: Private copy not working correctly
  • Next by thread: How a subview can inform to the controler that an event has happened?
  • Index(es):
    • Date
    • Thread