schmidt9
schmidt9

Reputation: 4538

Strange values in Debugging View in XCode

in my app for IPhone I pass some values (timestamps) to C++ library as int64_t. Before it I cast values from NSArray, where they are stored as double, to int64_t like that in .mm file:

int64_t f4 = (int64_t)[arr objectAtIndex:0];

The problem you can see on the picture (see link) is, that the shown selected value of variable f4 (left) is not the same as its printed value to the right. Further if I compare vars f1 and f4, f4 should be greater, than f1, concerning stored values, but it is not. Var f1 is returned from a function inside the library and the Debugging View shows right value.

Screenshot

Upvotes: 2

Views: 57

Answers (1)

trojanfoe
trojanfoe

Reputation: 122401

NSArray (and all Objective-C collection classes) can only hold objects. That means if you want to store numbers in a collection they need to be wrapped in an NSNumber object. For example:

[arr addObject:@(number)];

and to retrieve the value:

int64_t value = [arr[index] longLongValue];

However to answer the question, the values you are seeing are probably the addresses of the NSNumber objects, not the values contained within them.

Upvotes: 2

Related Questions