I have the following declarations in my model.h:
@interface Model: NSObject {
NSMutableArray *myMutableArray;
....
}
@property (nonatomic) double myDouble;
The corresponding @synthesize in model.m:
@synthesize myDouble;
I then have the following setter override:
-(void) setMyDouble: (double) newDouble{
myDouble = newDouble;
[myMutableArray addObject:[NSNumber numberWithDouble:myDouble]];
}
Putting a break point after the array assignment, the debugger shows the following for myMutableArray:
myMutableArray = (_NSArrayM *) 0x631c450 1 objects
0 = (NSCFNumber *) 0x631c6a0
So, my double does not seem to be properly getting into the array. I have subsequent assignments to this array for NSStrings that show up fine in the debugger. The values for both myDouble and newDouble are good (usually just an integer).
I’ve read several threads on assigning doubles to NSMutableArrays and haven’t discovered anything out of the ordinary. Any guidance would be appreciated.
Update
It appears that the code is correct, but I failed to understand that the debugger shows the NSNumber’s address rather than its value. Thank you everyone for responding, much appreciated! 🙂
It seems you are confusing with
0in0 = (NSCFNumber *) 0x631c6a0. That 0 is the index of the NSNumber in the array. If you retrieve the objects from the array and print it in NSLog, it would show you the correct values. Nothing seems to be wrong in your code.