同种类型不同名字的变量在for循环中操作

时间:2024-09-14 11:05:20

InfoViewController * info = [[InfoViewController alloc] init];

HeroViewController * hero = [[HeroViewController alloc] init];

MeViewController * me = [[MeViewController alloc] init];

FindViewController * find = [[FindViewController alloc] init];

NSMutableArray * viewArr = [[NSMutableArray alloc] initWithObjects:info,hero,find,me, nil];

for (int i = 0; i < 4; i++) {

UIViewController * vc = viewArr[i];

vc.title = titleArray[i];

}