Managed Object attribute returns wrong value...

I am using dot notation to set and get properties of a Managed Object. Upon trying to set is value... nslog shows the right value. when i try to use that value (int64_t type), it is returning an invalid value. Where I should be getting 5000, i get a 4.


Here is the code...

#ifdef DEBUG 
    NSLog(@"settingsToConsider = %@",settingsToConsider); 
#endif 
    if (settingsToConsider.goal!=0) 
    { 
        hObject.stepsGoal=settingsToConsider.goal; 
        int64_t goal = settingsToConsider.goal; 
        hObject.percentGoalCompleted = (int64_t)((steps/goal)*100); 
    }

The debugger output is as follows...


settingsToConsider =  (entity: Settings; id: 0xc640439cefdf322b  ; data: { 
    date = "2020-04-29 18:30:00 +0000"; 
    goal = 6000; 
    motivationalNotifOn = 1; 
    percentNotifOn = 1; 
    walkerType = 0; 
    weight = 118;


i added a breakpoint in the second line of the if statement and upon hovering pointer on goal of settingsToConsider.goal, it shows the value 4 instead of 6000.

Any idea what could be wrong?

Answered by ace.neerav in 418459022

Since both, steps and goals, were integers... the result of the division was an int. changed it to float and I get a correct value for p[ercentage goal completed.

Accepted Answer

Since both, steps and goals, were integers... the result of the division was an int. changed it to float and I get a correct value for p[ercentage goal completed.

Managed Object attribute returns wrong value...
 
 
Q