gpt4 book ai didi

objective-c - 我应该如何将 int 传递给 stringWithFormat?

转载 作者:IT老高 更新时间:2023-10-28 11:26:48 25 4
gpt4 key购买 nike

我尝试使用 stringWithFormat 在标签的文本属性上设置数值,但以下代码不起作用。我无法将 int 转换为 NSString。我期待该方法知道如何自动将 int 转换为 NSString。

我需要在这里做什么?

- (IBAction) increment: (id) sender
{
int count = 1;
label.text = [NSString stringWithFormat:@"%@", count];
}

最佳答案

这样做:

label.text = [NSString stringWithFormat:@"%d", count];

关于objective-c - 我应该如何将 int 传递给 stringWithFormat?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/384089/

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