What is the reason @strongify

ReactiveCocoa has a macro to prevent @weakify and @strongify from saving. From my understanding of @weakify do something like what I usually do by creating an __weak link for use in a block, but what about @strongify ?

Why do I need to make him strong again in the block?

Here is an example using the example:

 @weakify(self); [RACObserve(self, username) subscribeNext:^(NSString *username) { @strongify(self); [self validateUsername]; }]; 
+5
source share
1 answer

If you just use a weak link in a block, I can get free at runtime. But if you want me to remain in memory until the block completes, you need to convert the weak link back to the strong one.

+5
source

Source: https://habr.com/ru/post/1214472/


All Articles