我只是跑在我的项目铛静态分析器在这一点上拥有的对象的引用计数错误减量,和我收到以下警告:CSA警告:不是由主叫方
Incorrect decrement of the reference count of an object that is not owned at this point by the caller
请你能告诉我我的问题是什么。我通常可以很好地管理我的应用程序中使用的内存。
self.cupboardViewController = [[CupboardViewController alloc] initWithNibName:@"CupboardViewController" bundle:[NSBundle mainBundle]];
[self.window addSubview:self.cupboardViewController.view];
- (void)dealloc {
[[self cupboardViewController] release];//where I am getting the warning.
[super dealloc];
}
假设'cupboardViewController'标记为'retain',无论如何你都会泄漏它,因为它会自动保留你在示例第一行创建的新对象。您应该在将其分配给属性之前自动释放该对象,àla'self.cupboardViewController = [[[CupboardViewController alloc] init ...] autorelease];'。 – 2011-05-14 18:56:22
我这样做了,但它导致应用程序在一段时间后崩溃。 – 2011-05-14 19:11:22