Uitableview 从核心数据属性中获取值并求和
我正在使用下面的代码获取我的一个核心数据属性中的值,但我不知道是否可以提取它们并将它们相加,我想知道是否有人可以帮我做到这一点:Uitableview 从核心数据属性中获取值并求和,uitableview,core-data,nsfetchedresultscontroller,nsfetchrequest,Uitableview,Core Data,Nsfetchedresultscontroller,Nsfetchrequest,我正在使用下面的代码获取我的一个核心数据属性中的值,但我不知道是否可以提取它们并将它们相加,我想知道是否有人可以帮我做到这一点: AppDelegate *appDelegate =[[UIApplication sharedApplication] delegate]; self.contextTotal=[appDelegate managedObjectContext]; NSEntityDescription *entity= [NSEntityDescription entityFo
AppDelegate *appDelegate =[[UIApplication sharedApplication] delegate];
self.contextTotal=[appDelegate managedObjectContext];
NSEntityDescription *entity= [NSEntityDescription entityForName:@"CellSave" inManagedObjectContext:contextTotal];
NSFetchRequest *request= [[NSFetchRequest alloc] init];
[request setEntity:entity];
[request setResultType:NSDictionaryResultType];
[request setReturnsDistinctResults:YES];
[request setPropertiesToFetch:[NSArray arrayWithObject:@"smtrCbrData"]];
NSArray *objects= [contextTotal executeFetchRequest:request error:nil];
NSLog (@"results: %@",objects);
结果是:
Structure[1595:11603] results: (
{
smtrCbrData = "\U20ac 770.00";
},
{
smtrCbrData = "\U20ac 3,080.00";
}
有可能得到这些数字并将它们相加吗?我怎样才能做到这一点
谢谢如果您存储数字而不是格式化字符串,那就容易多了:-)谢谢您回答Martin…好的,如果我将属性改为number,那么有没有一种快速求和数字的方法?某种方法?请参见示例。