如何从数组中的字符串数组中获取每个值

How to fetch each value from Array of strings inside an Array

我在名为 officeList 的数组中有一个数组,格式如下:-

(
        (
        Prospect,
        Propose
    ),
        (
        Open,
        Fund,
        Propose
    ),
        (
        Settle,
        Review
    )
)

问题是我通过将 JSON 文件转换成一个数组得到了这个数组,结果我在一个数组中得到了这个字符串数组。我想要的是像这样一个一个地获取每个值:"prospect"、"propose" 等

我正在使用以下代码获取数据:

for (int i = 0;i<[_officelist count];i++)
{
    id val=[officeSize objectAtIndex:i];
    CGFloat val1=[val floatValue];
    UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, 20,val1,15)];

    newLabel.text=[NSString stringWithFormat:@"%@",_officelist[i]];

    newLabel.textAlignment = NSTextAlignmentCenter;


    [self.roadmapCollectionView addSubview:newLabel];

    x=x+val1;
    }

你试过这个吗

NSMutableArray *arr = [[NSMutableArray alloc] init];
for (NSArray *objArr in jsonArr) {
    for (NSString *str in ObjArr) {
        [arr addObject:str];
    }
} 

这里 jsonArr 是你从响应中得到的数组。现在使用 arr 访问您想要的每个对象。

希望对您有所帮助

应用下面的代码,

for (int i = 0; i < [_officelist count]; i++)
{
    NSArray *valList=[_officelist objectAtIndex:i];

    CGFloat val1 = [valList floatValue]; // Your Float val


    for (int j = 0; j < [valList count]; j++)
    {
         UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, 20,val1,15)];

         newLabel.text = [NSString stringWithFormat:@"%@",valList[j]];

         newLabel.textAlignment = NSTextAlignmentCenter;

         [self.roadmapCollectionView addSubview:newLabel];
    }

    x=x+val1;
}

希望对您有所帮助。