I have a complicated launch and I need to present and dismiss multiple view controllers. I have this bit of code where I need to use delays in presentation; I was wondering if my use of strongSelf
/ weakSelf
was proper in the following code with these dispatch_after
blocks, or if there are improvements that I should make to the code. I know it’s outdated Objective-C, I am working with an old, large code base.
__weak typeof(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{//CURRENT
__strong typeof(self) strongSelf = weakSelf;
[strongSelf presentViewController:strongSelf.coverVC animated:NO completion:^{
[strongSelf showWindowWithImage:NO];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
__strong typeof(self) strongSelf2 = weakSelf;
[strongSelf2 dismissViewControllerAnimated:YES completion:^{
strongSelf2.coverVC = nil;
[strongSelf2 hideWindow];
}];
});
}];
});