I have an entity called "Records", and it has an attribute named "amount" of NSDecimalNumber class.
And of course "Record" has other attributes such as "name","date", and so on.
Now I need to fetch only the amount attribute of all "Records" to sum them up,
to get better performance I just need the value of "amount", and I don't care the name, or date.
So how should I do?
Here's my code but I guess they are not professional enough.
NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"TransferRecord"];
request.includesSubentities = NO;
[request setPropertiesToFetch:[NSArray arrayWithObject:@"amount"]];
// [request setReturnsObjectsAsFaults:NO]; // I don't know whether I shoud use this
[request setResultType:NSDictionaryResultType];
NSError *error = nil;
NSArray *temp = [self.fetchedResultsController.managedObjectContext executeFetchRequest:request error:&error];
if (temp) {
// NSDecimalNumber *allTrans = [NSDecimalNumber zero];
// for (NSDecimalNumber *one in [temp valueForKey:<#(NSString *)#>)
NSLog(@"%@",[temp description]);
And I'm not clear about what the "faults" means.