I have the following code inside a method:
UIImageView* imageBlk = self.image;
self.finishBlock = ^{
imageBlk.hidden = YES;
}
Under ARC, will self get retained by the block because image is a property of self? Who owns imageBlk? Self?
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.
Will
selfbe retained by the block? No it will not. TheimageBlkvariable is not an instance variable so the block has no need to retainself. There is no worry of a retain cycle in your posted code.Who owns
imageBlk?imageBlkis a stack variable. The block will retain the variable. ARC takes care of this retention and well as properly releasing it when appropriate.Who owns
self? We can’t answer that from this code. Who ever has allocated the object will own it. Who ever has retained it also owns it.