gpt4 book ai didi

arrays - UILabel int 数组串联

转载 作者:行者123 更新时间:2023-12-03 17:03:37 27 4
gpt4 key购买 nike

好吧,我想读取一个连接到 UILabel 中的 int 数组,这是我的代码。我不知道如何连接它们,因为我正在构建一个数字过滤系统并希望在 UILabel 中显示剩余的数字。

-(IBAction)print {
for (int i = 0; i <= 100; i++){
if(myArray[i] != 0){
printScreen.text = [NSString stringWithFormat:@"%i,",myArray[i]];
}
}
}

最佳答案

试试这个代码:

-(IBAction)print {
NSMutableString *text = [[NSMutableString alloc] init];
for (int i = 0; i <= 100; i++) {
if(myArray[i] != 0) {
[text appendFormat:@"%d,", myArray[i]];
}
}
printScreen.text = text;
}

关于arrays - UILabel int 数组串联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17138669/

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