Reputation: 19873
I have an iPhone app that I am trying to debug.
One of my method returns a wrong value only when executing code, in the debugger it is fine.
int finalResponse = 0;
finalResponse = [data getInteger:@"final_response"];
then in the debugger
p finalResponse
(int) $0 = 130450628
p [data getInteger:@"final_response"]
(int) $1 = 0
I am expecting the 0 value, the other one is garbage. I don't understand why it yields different result depending on how I execute the function.
edit:
getInteger returns an int It uses an underlying c library which returns a (const void*), like this
int* value = get_dictionary_value("final_response", dictionary);
int val = (int) *value;
return val;
Upvotes: 1
Views: 172
Reputation: 36
Sometimes I experience weird debugging behavior when I debug using a release build; make sure you're using the right build phase for debugging.
Upvotes: 1
Reputation: 162722
Does the [poorly named -- shouldn't have a get
prefix] getInteger:
method do anything like advance an index into data
?
Or does getInteger:
return an NSNumber?
How is getInteger:
implemented?
With just that code, it is hard to say.
Upvotes: 3