Thursday, 14 February 2013

To fetch the core data attribute value of a specific entity.




NSManagedObjectContext *context;
    
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"FormQuestion" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
    
for (FormQuestion *info in fetchedObjects)
    {
        int temp=[info.formQuestionId intValue];
        if(temp>LastQuestion)
        {LastQuestion=temp;}
    }