【问题标题】:iphone core data executeFetchRequest memory issueiphone核心数据executeFetchRequest内存问题
【发布时间】:2010-11-26 16:29:00
【问题描述】:

我不断收到 -> 程序接收信号:“EXC_BAD_ACCESS”。

在下面的代码中,但我真的不明白为什么。

如果我注释掉“executeFetchRequest”行,它就会消失。

不应该[结果发布];只需要这些?

提前致谢, 马特

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    // fetch the delegate
    TestingAppDelegate *app = (TestingAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *managedObjectContext = [app managedObjectContext];

    // construct the request
    NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; 
    [request setEntity:[NSEntityDescription entityForName:@"Client" inManagedObjectContext:managedObjectContext]]; 

    NSError *error;
    NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
    [results release];
}

【问题讨论】:

    标签: iphone core-data memory-leaks ios-simulator


    【解决方案1】:

    我相信resultsexecuteFetchRequest:error: 的结果,应该已经被自动释放了。因为您显式调用[results release],所以当当前自动释放池耗尽时,您过度释放该对象。删除[results release] 行,看看是否能解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 2014-07-24
      相关资源
      最近更新 更多