Thursday, 14 February 2013

To find a specific attribute value for a entity from core data then we use NSpredicate for logical conditions.


 NSManagedObjectContext *context = [[SharedVars sharedInstance]localContext];
        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"formQuestionId == %i", i];
        [fetchRequest setPredicate:predicate];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"FormQuestion" inManagedObjectContext:context];
        [fetchRequest setEntity:entity];
        
        NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
        for (FormQuestion *info in fetchedObjects)
        {
            
          //  [info setIsEnabled:[NSNumber numberWithInt:0]];
// edit and see data using info.yourAttributeId;
        }