2

Why NSNumber of 0 cannot be converted to correct NSInteger/NSUInteger value?

NSUInteger a = [@0 unsignedIntegerValue]; // a become nil

Why is a in the above line of code nil. Shouldn't it be equal to 0?

In the console:

(lldb) po [@0 intValue]
0

(lldb) po [@0 integerValue]
<nil>

(lldb) po [@0 unsignedIntegerValue]
<nil>

Update:

(lldb) p [@0 unsignedIntegerValue]
(NSUInteger) $0 = 0
Alston
  • 1,166
  • 2
  • 13
  • 26

1 Answers1

3

Use p not po

(lldb) p [@0 integerValue]
(NSInteger) $1 = 0
(lldb) p [@0 intValue]
(int) $2 = 0
(lldb) p [@0 unsignedIntegerValue]
(NSUInteger) $3 = 0
Leo
  • 24,596
  • 11
  • 71
  • 92
  • Thanks for reply. Clear myself, I'm assigning `@0` to a NSUInteger variable, and it turns out to be a `nil`. Is there any advise not to use NSInteger/NSUInteger? – Alston Jun 25 '15 at 09:19
  • [@0 integerValue] is not a object. You should use p value instead of po object – Hugo Aug 05 '15 at 06:39