How to convert int to NSString?

Yogini picture Yogini · Sep 3, 2009 · Viewed 153.9k times · Source

I'd like to convert an int to a NSString in Objective C.

How can I do this?

Answer

VisioN picture VisioN · Apr 10, 2013

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;