views:

21

answers:

0
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName: @"Data" inManagedObjectContext:managedObjectContext];
[request setEntity:entity];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"prospectId=%d", 123];
[request setPredicate:predicate];

NSError *error;
NSMutableArray *mutableFetchResults=[[NSMutableArray alloc]init];
mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];

if (mutableFetchResults == nil) 
{
    UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Error retrieving data" message:@"No data found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
}

NSLog(@"fetched = %@",mutableFetchResults);

[mutableFetchResults release];
[request release];

What is the mistake I am doing???