Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] is it shallow copy or deep copy? and why things are not retrieved well?



On 18 Dec 2006, at 1:45 AM, JongAm Park wrote:

I intentionally didn't release the string created with CFStringCreateWithFormat, worrying if the dictionaryWithObjectsAndKeys method does shallow copy.
...
So, can anyone tell me how the method keeps the content in the "array", and why the value is not displayed?

It is well-documented that Cocoa collection objects retain their values and copy their keys. See the general documentation for NSDictionary. (I found this from Andy Lee's excellent Cocoa interface browser AppKiDo, available at <http://homepage.mac.com/aglee/ downloads>.) Release the string after adding it to the dictionary (unless you have an independent need for the nonreleased value).


As for the problem with the strings derived from encoding_constant [i], have you used the debugger to step through your code and examined encoding_constant[i] and the strings? This will involve computing the strings outside the dictionary initialization, but may make matters much clearer.

	-- F

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >[Q] is it shallow copy or deep copy? and why things are not retrieved well? (From: JongAm Park <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.