值为 int i 的变量名
我尝试做了这样的事情:
for (int i=0; i<8; i++) {
UIButton *btn_i = [[UIButton alloc] initWithFrame:CGRectMake(0 * numberRowsOfMenu, 0 * heightOfRow, btnWidth, btnHeight)];
}
其中 UIButton *btn_i
是 btn_
+ i
的值。
在 Obj-C 中可能吗?
i try made something like this:
for (int i=0; i<8; i++) {
UIButton *btn_i = [[UIButton alloc] initWithFrame:CGRectMake(0 * numberRowsOfMenu, 0 * heightOfRow, btnWidth, btnHeight)];
}
where UIButton *btn_i
is btn_
+ value of i
.
it is possible in Obj-C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的意思是您想要以 btn_0、btn_1 等名称结束变量吗?
不,你不能这样做。你可能会更好地使用这样的东西:
Do you mean you want to wind up with variables with names like btn_0, btn_1, etc?
No, you cannot do this. You might be better off with something like this: