objective c convert int to string
To convert an int
to a NSString
in Objective-C, you can use the stringWithFormat:
method of the NSString
class. Here's an example:
int number = 42;
NSString *string = [NSString stringWithFormat:@"%d", number];
In this example, the stringWithFormat:
method is used to create an NSString
object by formatting the int
value number
as a string. The %d
format specifier is used to represent an int
value.
That's it! The string
variable will now contain the int
value converted to a string.