gpt4 book ai didi

objective-c - 简单数组的问题 - Cocoa

转载 作者:行者123 更新时间:2023-12-03 16:51:18 25 4
gpt4 key购买 nike

我想知道是否有可能执行以下操作:

我有一个方法,例如:

one = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3", nil];
two = [[NSMutableArray alloc] initWithObjects:@"4",@"5",@"6", nil];

-(void)getStringAndChooseArray:(NSString *)nameOfArray {
//What i want to do is something like:
NSLog(@"The array %@ has got %i objects",nameOfArray,[nameOfArray count])
//Of course it is giving me an error since nameOfArray is a string..

//I know it is hard to understand,
//but what I'm trying to do is to call this method
//pass a string variable, which is named as one of the two arrays,
//and using it to do the rest..

}

如何使用字符串来识别数组并对其进行操作?

提前致谢!

最佳答案

将数组存储在字典中,并使用您想要引用它们的名称作为其相关键。

关于objective-c - 简单数组的问题 - Cocoa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13805512/

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