Here's the situation:
In async functions, I capture a weakSelf.
__block auto weakSelf = self;
Then, inside the block, I capture a strongSelf of that weakSelf.
[_someIvar someAsyncMethod:^{
__strong auto strongSelf = weakSelf;
}];
But, if strongSelf is nil, I do some error handling and reporting.
if (!strongSelf) {
_NotifyDelegate(someDeallocationError); // C
}
The whole thing:
__block auto weakSelf = self;
[_someIvar someAsyncMethod:^{
__strong auto strongSelf = weakSelf;
if (!strongSelf) {
// How can I trigger this line?
_NotifyDelegate(someDeallocationError); // C
}
}
}];
This is all legacy code, and I'm adding unit tests using OCMock. How can I make strongSelf nil at runtime and trigger that delegate notification?