objective c - What's the correct way to accumulate NSDecimalNumber values? -


i trying accumulate nsdecimalnumber values obtained array (apptdataarray, obtained coredata store; acurrentcharges defined nsdecimalnumber). code:

        nsdecimalnumber *accumulatedfees = 0;         for(int = 0; < apptdataarray.count; i++)  {             appointmentinfo *currentappointment = [apptdataarray objectatindex: i];             accumulatedfees = [accumulatedfees decimalnumberbyadding: currentappointment.acurrentcharges];  //  <----  not accumulating         }         oaccumulatedcharges.text = [nsstring stringwithformat:@"%@",accumulatedfees]; 

my problem line marked not accumulating doing -- not accumulating. doing wrong?

the variable accumulatedfees not being initialized correctly. try setting way:

nsdecimalnumber *accumulatedfees = [nsdecimalnumber zero]; 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -