NSNumber with 0 convert to NSInteger/NSUInteger become nil

1.1k views Asked by At

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
1

There are 1 answers

2
Leo On BEST ANSWER

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