如何以干净的方式在一个块中实例化 2 个 BOOL 变量?
如下所示,它正在工作,但我有“在此块中强烈捕获'自我'可能会导致保留周期”,这显然不好......
[notificationCenter addObserverForName:UIApplicationDidEnterBackgroundNotification
object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
isApplicationOnForegroundMode = NO;
isApplicationOnBackgroundMode = YES;
} ];
[notificationCenter addObserverForName:UIApplicationDidBecomeActiveNotification
object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
isApplicationOnForegroundMode = YES;
isApplicationOnBackgroundMode = NO;
} ];