In a lot of question it is asked if its ok to use self in blocks. The answer is no, to avoid retain cycle.
Now when i use an "ivar" in my block in my UIViewController it should be fine. But when i use:
- (void)viewDidLoad
{
[_customCell setChangedValueBlock:^{
if(_object != nil){
NSLog(@"This is a sample");
}
}];
}
The dealloc method never called:
-(void)dealloc{
NSLog(@"Dealloc");
}
When i remove the if(_object != nil){, the dealloc method is called.
Should i make weak reference to the _object before passing it to the block?