How do I convert NSUInteger
value to int
value in objectiveC?
and also how to print NSUInteger
value in NSLog
, I tried %@,%d,%lu
these are not working and throwing Ex-Bad Access error.
Thank you
How do I convert NSUInteger
value to int
value in objectiveC?
and also how to print NSUInteger
value in NSLog
, I tried %@,%d,%lu
these are not working and throwing Ex-Bad Access error.
Thank you
NSUInteger intVal = 10;
int iInt1 = (int)intVal;
NSLog(@"value : %lu %d", (unsigned long)intVal, iInt1);
for more reference, look here
NSUInteger
. So the last line should be NSLog(@"the value is : %lu %d", (unsigned long)intVal, iInt1);
. –
Stereochrome Explicit cast to int
NSUInteger foo = 23;
int bar = (int)foo;
Although
NSLog(@"%lu",foo);
will work OK on current builds of OSX. It's not safe, as NSUInteger is typedeffed as unsigned int on other builds. Such as iOS. The strict answer is to cast it first:
NSLog(@"%lu",(unsigned long)foo);
Hi all its working for me ...
I tried this..
NSUInteger inbox_count=9;
NSLog(@"inbox_count=%d",(int)inbox_count);
//output
inbox_count=9
thank to all..
It's simple as this,
NSUInteger uintV = 890;
int intVal = (int) uintV;
NSLog(@"the value is : %lu", (unsigned long)intVal);
this will print something like this,
the value is : 890
© 2022 - 2024 — McMap. All rights reserved.
%lu
, not@lu
. – Kathlyn