Reputation: 27133
Will this block cause a memory leak issue, because I am not using weakified sell:
[KNApi getCouponsWithSearchString:self.searchString withCouponsCount:self.coupons.count withSuccess:^(id object) {
[self.coupons addObjectsFromArray:object[@"items"]];
[self.hud hide:YES];
[self.theTableView setHidden:NO];
[self.theTableView reloadData];
} withFailure:^(id object) {
[self hideLoadingIndicatorWithError:object];
}];
I know for example if we have [KNApi getCouponsWithSearchString...
as a block property in self class, then it causes an issue.
So suppose that our stack will be destroyed and I will get a success invocation before that. Will it cause an issue with requesting itself?
Upvotes: 1
Views: 845
Reputation: 1156
YES YOU SHOULD USE A WEAK SELF! Its a good practice
check this section, link below "Avoid Strong Reference Cycles when Capturing self"
Upvotes: 0
Reputation: 2165
It depends. Does KNApi retain the block? Does self retain KNApi? What block does is it retains self strongly. It's no different than any other retain. You don't have to weakly retain self as long as you're sure what's happening with the block.
Upvotes: 1