How can I say which type of objects a closure will retain? Is there any particular rule or list of types that closure will/will not retain?
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.
All Objective-C objects are retained. Everything else is simply copied. For example, here are three variables:
All three variables can be read from inside a block. However, only
arraywill be retained, since it is the only variable on which it’s possible to call theretainmethod.Special care should be taken to make sure that the place
ptrpoints to still exists when the block is executed, since it is a pointer that cannot be retained.