将int转换为NSString [英] Converting int into NSString

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

问题描述

我想转换 NSString 中的随机int数,然后将NSString分配给另一个 NSString 但是它崩溃应用程序

I want to convert a random int number in the NSString and then assign the NSString to another NSString but it crashes the app

我正在做以下事情

int mynumber =(arc4random() % 1000 );

unique = [NSString stringWithFormat:@"%d",mynumber];

   NSLog(unique)

   NSString*test=unique;

当我写最后一行时它会崩溃;

it gives crash when i write last line;

当我输入唯一字符串时,它还会打印值。

It also prints values when I nslog the unique string.

推荐答案

如果你想把int改为字符串

If you want to change the int to string

NSString *strFromInt = [NSString stringWithFormat:@"%d",yourintvalue];

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆