ios - If a strong property has a block that refers to self, is that a retain cycle? -


for instance:

[self.contentwrapperview addgesturerecognizer:    [uitapgesturerecognizer recognizerwithhandler:^(uigesturerecognizer *sender,                                                     uigesturerecognizerstate state,                                                     cgpoint location) {         if (self.customediting) {         [self seteditingmode:no animated:yes];       }     }]]; 

where contentwrapperview strong property on self, , presuming contentwrapperview has strong reference recognizer block. using self in block going lead retain cycle? part don't quite understand.

yes lead retain cycle.

the workaround incase care is

__weak id weakself = self; [self.contentwrapperview addgesturerecognizer:[uitapgesturerecognizer recognizerwithhandler:^(uigesturerecognizer *sender, uigesturerecognizerstate state, cgpoint location) {     if ([weakself customediting]) {         [weakself seteditingmode:no animated:yes];     } }]]; 

Comments