I am doing deep copies of NSMutableDictionary with this: https://stackoverflow.com/a/5453600/555690
Like this:
NSMutableDictionary *myCopy = [originalMutableDictionary mutableDeepCopy];
Do I have to release myCopy?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m assuming you’re not using ARC. The answer should be “yes” since it’s created with copy. See the NARC rules here:
Do you need to release parameters of methods at the end of them in Objective-C?
In that particular code, the
retis created usingdictionaryWithObjectsso it would already be autoreleased, but then there’s an extraretainthat’s called explicitly. So the answer is… still “yes,” which follows the ownership policy.