NSString *one = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"Test1",@"text", nil];
NSString *two = [NSDictionary dictionaryWithObjectsAndKeys:@"2",@"id",@"Test2",@"text", nil];
NSString *three = [NSDictionary dictionaryWithObjectsAndKeys:@"3",@"id",@"Test3",@"text", nil];
_options = [NSArray arrayWithObjects:one,two,three,nil];
这是我正在使用并在我的代码中正常运行的代码。现在我想要它动态,比如
int total = 20;
NSMutableArray *arr = [[NSMutableArray alloc] init];
for(int x = 0; x < total; x++)
{
[arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"Test1",@"text", nil]];
}
但它不起作用。谁能帮我解决这个问题。
主要代码就像
_options = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"Test1",@"text", nil],[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"Test1",@"text", nil],[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"Test1",@"text", nil],nil];
我想动态创建它,就像值会去 1-100。我怎样才能做到这一点