I just wanted to know: will the retain count of an object be incremented if it is added to an array or dictionary in Objective-C? Can I release a particular object immediately after adding it to an array or dictionary?
Share
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.
Hariprasad,
NS[collection name here] retain objects added to them as NSResponder noted. A few other facts:
after adding”, the short answer is
yes. Often times I do an
autoreleasefor objects that arebound for containment in a
collection and won’t be needed outside the collection.
object from a collection, the
reference count is decremented. If
you want to ensure it won’t be
deleted from memory (next pool
sweep) you need to retain the
object.