On Apr 20, 2010, at 1:06 PM, Brent Fulgham wrote:

Can anyone clarify whether the NSMutableArray object's "setArray"
performs a deep copy of the NSArray provided,
or does it simply build an NSMutableArray object with
additionally-retained elements pointing back to the source object?

It does not copy any of the elements, just retains them.

In general I can't think of any deep-copy behavior in any of the Cocoa collection classes. With one exception*, objects only get copied when you explicitly call -copy. And even -copy is implemented shallowly in existing classes (so copying an NSArray results in a new array that contains the same objects, not copies of those objects.)

—Jens

* The exception is the way NSDictionary copies the objects that are set as keys, to prevent them from being mutated behind its back._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to