Closed wMellon closed 4 years ago
try this:
@weakify(self) [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"MakeDoctorOrderNetRequest" object:self] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification * _Nullable x) { @strongify(self) //block }];
@wMellon the block will execute more than once When the notification post
is because of memory leak, add takeUntil:self.rac_willDeallocSignal
method can resolve this question.
@wMellon
the block will execute more than once When the notification post
is because of memory leak, addtakeUntil:self.rac_willDeallocSignal
method can resolve this question.
thanks
try this:
@weakify(self) [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"MakeDoctorOrderNetRequest" object:self] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification * _Nullable x) { @strongify(self) //block }];
thanks
I put the following code in ViewController. When I close the ViewController and open again, then the block will execute more than once When the notification post. Only when I restart the APP and open this ViewController first time, the block execute once. Why? Can I program to delete it when I close the ViewController(example, in the dealloc method)?