我有一个复杂的发布,我需要展示和取消多个视图控制器.我有一段代码,其中我需要在表示中使用延迟;我想知道在下面这dispatch_after
个块的代码中,我使用strongSelf
/weakSelf
是否合适,或者我是否应该对代码进行改进.我知道这是过时的Objective-C,我正在使用一个旧的、大型的代码库.
__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];
}];
});
}];
});