Swa*_*way 0 iphone memory-leaks core-data ios-simulator
我一直收到 - >程序接收信号:"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];
}
Run Code Online (Sandbox Code Playgroud)
我相信results,结果executeFetchRequest:error:应该已经自动释放了.因为您正在显式调用[results release],所以当当前自动释放池耗尽时,您将过度释放该对象.删除该[results release]行,看看是否修复它.