2009-09-09 4 views
0

계속해서 -> 프로그램 수신 신호 : "EXC_BAD_ACCESS"가 표시됩니다.iphone 핵심 데이터 executeFetchRequest 메모리 문제

다음 코드에서 왜 그 이유는 모르겠다.

"executeFetchRequest"행을 주석 처리하면 사라집니다.

[결과 릴리스]가 아니어야합니다. 그게 다 필요한거야? 사전에

감사합니다, 매트 내가 results 생각

// 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]; 
} 

답변

5

executeFetchRequest:error:의 결과는 이미 오토 릴리즈해야한다. 명시 적으로 [results release]을 호출하기 때문에 현재의 자동 릴리스 풀이 비었을 때 해당 객체를 과도하게 릴리스합니다. [results release] 행을 제거하고 수정했는지 확인하십시오.

+0

감사합니다. 그것은 그것을 고쳤다! 건배. – Sway