Objective c 局部变量导致ARC内存泄漏
我有一个简单的问题,没有答案 我有一个UIAlertView局部变量,如下所示Objective c 局部变量导致ARC内存泄漏,objective-c,ios7,memory-leaks,automatic-ref-counting,local-variables,Objective C,Ios7,Memory Leaks,Automatic Ref Counting,Local Variables,我有一个简单的问题,没有答案 我有一个UIAlertView局部变量,如下所示 - (void)insertNewObject:(id)sender { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message"
- (void)insertNewObject:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
message:@"message"
delegate:nil
cancelButtonTitle:@"cancelButtonTitle"
otherButtonTitles:@"otherButtonTitle", nil];
[alert show];
}
当我执行-(void)insertNewObject:(id)sender
方法时,每当UIAlertView的引用计数一个接一个地增加时,它们都不会被丢弃
所以,任何问题都与ARC有关。在执行
-(void)insertNewObject:(id)sender
方法时,我需要保持活动对象的计数不增加。并且您肯定是在该源文件上启用了ARC的情况下编译的?是的。我已经启用了ARC,这是一个使用xcode生成的示例项目。