本文介绍了Xcode 4变量变量名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我是iOS编程的新手,我需要一点帮助.

我知道这是不可能的-但是您将如何以最简单的方式做到这一点?:

我有一个包含20个不同播放器的播放列表-我需要给个名字,所以我在界面生成器中创建了20个不同的文本字段
并将它们分配到头文件中,如下所示:

Hi all

I´m a newbee to iOS Programming and i need a little help.

I know the subject isn´t possible - but how would you do this the easiest way?:

I have a playlist of 20 different players - witch i need to give a name, so i created 20 different text fields in interface builder
and assigned them in the header file like this:

IBOutlet UITextField *player1;
IBOutlet UITextField *player2;
IBOutlet UITextField *player3;
IBOutlet UITextField *player4;
IBOutlet UITextField *player5;
and so on....



每个出口都分配给一个文本字段

我存储了这些值,稍后再编辑名称,而我真正想要的是这样的内容:



and every outlet is assigned to a text field

i store these values and come back later to edit the names and what i really want is something like this:

for (int i = 0; i<20;i++)
{
player{i+1}.text = [playerlist objectatindex:i];
}



据我所知,这是不可能的-但这是最简单的方法吗?
代替手动方式:



wich i know isn''t possible - but how is this done the easiest way then ?
in stead of the manual way:

player1.text = [playlist objectAtIndex:0];
player2.text = [playlist objectAtIndex:1];
player3.text = [playlist objectAtIndex:2];
player4.text = [playlist objectAtIndex:3];
player5.text = [playlist objectAtIndex:4];
player6.text = [playlist objectAtIndex:5];




Br
Michael




Br
Michael

推荐答案


这篇关于Xcode 4变量变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 10:32
查看更多