objective c - Unable to change NSNumber to Double and do some calculations with it -


my problem have array holds double values

nsarray *level4results = [context executefetchrequest:request error:&error]; 

then sum values in array

nsnumber *l4sum = [level4results valueforkeypath:@"sum.self"]; 

the next thing want divide 8 sum of array... , stuck. have tried many options , ways of doing either way kept on getting different error. have in code

double l4average = ([l4sum doublevalue] / 8); 

however throwing following error

* terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nsarrayi doublevalue]: unrecognized selector sent instance

help in solving problem appreciated. thanks

it's collection operator. line:

nsnumber *l4sum = [level4results valueforkeypath:@"sum.self"];

should written:

nsnumber *l4sum = [level4results valueforkeypath:@"@sum.self"];


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -