I'd like to convert an int to a NSString in Objective C.
How can I do this?
To convert an Int value to a String value in Swift, use String(). String() accepts integer as argument and returns a String value created using the given integer value.
Primitives can be converted to objects with @() expression. So the shortest way is to transform int to NSNumber and pick up string representation with stringValue method:
NSString *strValue = [@(myInt) stringValue]; or
NSString *strValue = @(myInt).stringValue;
NSString *string = [NSString stringWithFormat:@"%d", theinteger];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With