In ReactiveCocoa there is macro to prevent retain cycle @weakify
and @strongify. From my understanding @weakify
do something like what I usually do that is create __weak
reference for using in the block, but what about @strongify
?
Why do I need to make it strong again in the block?
Here is some sample usage:
@weakify(self);
[RACObserve(self, username) subscribeNext:^(NSString *username) {
@strongify(self);
[self validateUsername];
}];
self
object and you want to be sure theself
is valid until the block runs out of its scope (so your block won't make a half-done job on yourself
), you need to get it strong. – Cronk