MyAppDelegate 正在做一些后台工作,在此期间需要刷新几个视图,因此我保存了对创建的每个控制器的引用。
@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
SomethingController *currentSomethingController;
}
@property (nonatomic, retain) SomethingController *currentSomethingController;
这样做是为了打开控制器:
- (void)openSomethingController {
MyAppDelegate * app = [[UIApplication sharedApplication] delegate];
app.currentSomethingController = [[SomethingController alloc] init];
[self presentModalViewController:app.currentSomethingController animated:NO];
}
这在控制器内部被调用来关闭它:
- (void)dismissSelf
{
MyAppDelegate * app = [[UIApplication sharedApplication] delegate];
[app.currentSomethingController release];
app.currentSomethingController = nil;
[self dismissModalViewControllerAnimated:NO];
}
在 MyAppDelegate 中,控制器正在向控制器发送消息:
- (void)longRunningBackgroundTask {
[currentSomethingController performSelectorOnMainThread:@selector(updateData) withObject:nil waitUntilDone:YES];
}
如果我执行 Product->Analyse,我会收到“潜在泄漏”和“不正确递减”警告。什么是正确的方法或假设我的方法没问题,我如何告诉分析工具忽略这些行?