I am trying to save a block in an instance variable in my project. Here where I declare an instance variable:
@property (nonatomic, copy)void (^loginCompletedTask)();
I assign this variable by calling this method:
- (void)requireLoggedInForBlock:(void (^)())completion { self.loginCompletedTask = completion;
After the first line of this method, self.loginCompletedTask is non-nil and logs in a debugger of type NSMallocBlock . However, when I really need to start the block after the login warning view is returned, it becomes null.
I tried:
strong declaration instead of copy ,- Setting
self.loginCompletedTask = ^{completion();}; , - Setting a variable directly, instead of using a property (
_loginCompletedTask = ... ).
What am I missing?
source share