gpt4 book ai didi

objective-c - 如何使用 objective-c 将整数添加到字符串中?

转载 作者:太空狗 更新时间:2023-10-30 03:21:16 25 4
gpt4 key购买 nike

我是一个java程序员,我发现Java很擅长做string。

如果我想做这个 objective c,我怎么在 objective c 中做?

System.out.println("This is a " + 123 + " test");

最佳答案

要将整数放入字符串中,您可以这样做:

int n = 123;
NSString *s = [NSString stringWithFormat:@"This is a %d test", n];

还有许多其他方法。但是通过 + 运算符将字符串与整数连接起来并不是其中之一。 :)

关于objective-c - 如何使用 objective-c 将整数添加到字符串中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2455200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com