Convert NSUInteger to string with ARC
nsstring, nsuinteger, objective-c
Solution
You probably have a variable of type NSUInteger, something like
NSUInteger myNumber;
Then you can convert it to a string like this:
NSString *text = [NSString stringWithFormat:@"%li", myNumber];
A solution that I prefer now is this:
NSString *text = [NSString stringWithFormat:@"%@", @(myNumber)];
This helps avoid compile warnings about incorrect number formatting codes (after a long time I still get confused in them).
Problem
I'm trying to cast a NSUInteger to a string so I can print a message. From searching, it seems like I need to use stringWithFormat, but I am getting an error that an implicit cast not allowed with ARC. Here's the line in question: ``` NSString *text = [[NSString stringWithFormat: (@"%li", NSUInteger)]; ``` I've tried changing the format specifier to %lu with no help. Thanks.