Yes. You're good there. Only variables inside the block itself are retained.
weakSelf on queue calling method that use self inside
-
18-06-2023 - |
Question
Is it ok if i do something like:
-(void)example{
__weak __typeof__(self) weakSelf = self;
dispatch_queue_t dispatchQueue = dispatch_queue_create("q_getRestaurants", NULL);
dispatch_async(dispatchQueue, ^{
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf doSomething];
});
});
}
-(void)doSomething{
//can i use self inside this method????
self.view.backgroundColor = [UIColor redColor];
}
The thing is that i wanna know if there is ok if i use self inside the do something method that is being called from a queue that has a weakSelf call.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow