Core Data NSFetchRequest setResultType:NSDictionaryResultType not working

When setting a NSFetchRequest result type to NSDictinaryResultType, zero objects are returned. If I remove setPropertiesToFetch and setResultType, all the objects are returned.

Any ideas?

  • IOS 8 UITableView self-sizing cells jump/shift visually when a new view controller is pushed
  • iCloud KeyValue store not recognized on first launch
  • Prefilled version of Core Data?
  • Horizontal UIScrollView and hundreds of thumbnail images in iOS?
  • Add 90 min to NSDate
  • SDK to Read PPT , xls and .doc file in iOS
  • NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Alert" inManagedObjectContext:_managedObjectContext];
    [request setEntity:entity];
    
    NSDictionary *entityProperties = [entity propertiesByName]; 
    [request setPropertiesToFetch:[NSArray arrayWithObject:[entityProperties objectForKey:@"test"]]];
    [request setResultType:NSDictionaryResultType];
    
    NSError *error;
    NSArray *result = [_managedObjectContext executeFetchRequest:request error:&error];
    
    if (result == nil) {
        NSLog(@"Error: %@", [error localizedDescription]);
    }
    

    Solutions Collect From Internet About “Core Data NSFetchRequest setResultType:NSDictionaryResultType not working”

    The problem was I needed to save the mangedObjectContext after inserting new objects. Once I did that I get the results I was looking for.