gpt4 book ai didi

objective-c - 动态变量名称 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:23:53 27 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
create multiple variables based on an int count
Objective C Equivalent of PHP's “Variable Variables”

我想在 for 循环中使用一些动态变量名称,但对如何实际引用这些变量感到困惑。

我有一系列 UILabel 标题 poll0 - poll8。使用 for 循环,我将它们的 text 值设置为从数组中相应数字引用的另一个值。例如:

for (int i = 0; i < [pollData count]; i++) {
label(i value).text = [NSString stringWithFormat:@"%@", [[pollData objectAtIndex:i] toString]]; //sorry for the java-esque method names, just create what I'm used to
}

我如何使用那个 i 值?

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