本文介绍了如何将 int 转换为 NSString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Objective C 中将 int 转换为 NSString.

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

我该怎么做?

推荐答案

Primitives 可以通过 @() 表达式转换为对象.所以最短方法是将 int 转换为 NSNumber 并使用 stringValue 方法:

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];

NSString *strValue = @(myInt).stringValue;

这篇关于如何将 int 转换为 NSString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:00
查看更多