ios - Tally a Dictionary Value For Key Object -
i guess i'm tired today. can't come correct way tally number object in loop used build pdf report. need keep running total (+=) on object , put @ bottom of report. here i'm referring pdf context. (inside loop). dictionary created fetched array.
mynewstring = [decimalformatter stringfromnumber:[resultsdict valueforkey:@"dispatchmtmiles"]]; [mynewstring drawinrect:cgrectmake(525, currentpagey, 40, 15) withfont:loadlinefont linebreakmode:nslinebreakbytruncatingtail alignment:nstextalignmentright];
i need keep running total of dispatchmtmiles in core data integer16 type. help.
if understand right, , have array of dictionaries @"dispatchmtmiles" key, can sum them key coding function, example:
nsarray *a = @[@{@"x": @1}, @{@"x": @2}, @{@"x": @3}]; nsnumber *sum = [a valueforkeypath:@"@sum.x"]; // 6
Comments
Post a Comment