David542
David542

Reputation: 110237

NSUInteger casting

I have the following statement:

NSLog(@"The count of the book is now: %i", [book.book count]);

This gives me a caution that I'm using the wrong format argument.

Upvotes: 1

Views: 44

Answers (1)

Mick MacCallum
Mick MacCallum

Reputation: 130193

You can, but probably shouldn't print it as a signed integer, because it may contain values that would overflow the signed integer. Additionally, NSUInteger is either defined as unsigned int, or unsigned long depending on wether the platform is 32 or 64 bit, so you can handle this by casting to unsigned long and then using the unsigned long format specifier.

NSLog(@"The count of the book is now: %lu", (unsigned long)[book.book count]);

Upvotes: 1

Related Questions