I have a variable with an NSInteger type.. if I set a breakpoint on the variable and print it's output into the log, I get the expected value (ie 0).. however it looks very different on the debugger stacktrace variable list (180821440).. can someone explain what's going on?

enter image description here

I'm running Xcode 5.1.1 with Apple LLVM 5.1 having a None optimization level for the compiler

有帮助吗?

解决方案

from the discussion of Martin R and Droppy above.. I figured out this was happening.

In the original code I was getting the taxiAmount value from an http call like so:

[serverGateway_ getTaxiAmountWithCoordinate:coordBlock onSuccessBlock:^(NSData *responseData)
 {
     [parser_ parseTaxiAmountWithData:responseData onSuccessBlock:^(NSNumber *taxiAmount)
     {
          [cityManager_ setTaxiAmount:taxiAmount];

so I was sending an NSNumber value to a NSInteger varialbe

- (void)setTaxiAmount:(NSInteger)taxiAmount
{
    taxiAmount_ = taxiAmount;
}

in this case typing po taxiAmount returned 0, whereas p taxiAmount returned 180520272:

so what was causing this whole hoopala was treating a NSNumber as an NSInteger.. obviously correcting the line to

[cityManager_ setTaxiAmount:[taxiAmount integerValue]]; 

fixed the problem (and cleared the confusion)

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top