I am using automatic reference counting. And I want object to live until some callback will be executed:
Foo *obj = [[Foo alloc] init];
[obj someMethod: @"AAA", ^(NSError * _Nullable error) {
//callback
});
I need obj
to be alive until "callback" will be called,
but I don't actually use it in callback.
For now I "solve" it with:
[obj someMethod: @"AAA", ^(NSError * _Nullable error) {
//callback
NSLog(@"To make sure that obj alive print it: %@", obj);
});
But this looks weird. May be there is some language construction for such case, or there is some typical workaround for this except printing to log?