开发者

Determining value of NSUInteger

开发者 https://www.devze.com 2022-12-14 07:29 出处:网络
I\'d like to view the value of an NSUInteger at any given time.I assign the value below: NSUInteger test = -1;

I'd like to view the value of an NSUInteger at any given time. I assign the value below:

NSUInteger test = -1;

Then try to view it in the debugger:

(gdb) po test
Cannot access memory at address 0xffffffff
(gdb) p test
$1 = 4294967295
Current language:  auto; currently objective-c

Fa开发者_运维知识库r as I know, it is a value type. Where is -1?


You're using an NSUInteger, which is unsigned. As such, any negative values assigned will actually be interpreted very large positive values.

You want to use NSInteger which is signed (and therefore can be both positive and negative values). You should then be able to do (gdb) p test to see the value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号