How to convert int to NSString?

后端 未结 4 1124
不思量自难忘°
不思量自难忘° 2020-11-27 12:42

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

How can I do this?

4条回答
  •  迷失自我
    2020-11-27 13:06

    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;
    

提交回复
热议问题