I've created an Entity with attribute price
with type NSDecimal
. I try to count the sum of all prices in the entity:
@property(nonatomic,strong)NSArray *coisArr;
@property(nonatomic,strong)NSDecimalNumber *sum;
_sum =[_coisArr valueForKeyPath:@"price.floatValue"];
NSLog(@"Result: %@",_sum);
The result NSlog
returns me:
Result: (
"0.56",
"0.85",
1,
1,
12
)
Do I really get the sum? I try to show the result in a UILabel
NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle: NSNumberFormatterCurrencyStyle];
_lblTotalValue.text = [formatter stringFromNumber: _sum];
but get it empty. So where I went actually wrong?