iOS - Make a copy of a array object into another

随声附和 提交于 2019-12-05 22:59:29

I assume you have a 2-dimensional array and since I don't know how your objects within the array look like I take the id type and the method valueForKey:

 NSMutableArray *tmp = [[NSMutableArray alloc] init];
 for(NSArray *dim1Array in yourMultidimensionalArray)
 {
    for(id obj in dim1Array)
    {
       if([[obj valueForKey:@"name"] isEqualToString:@"Hello"])
       {
          [tmp addObject:dim1Array];
          break; // I assume you only want to add it once
       }
    }
 }
Hank

This is how you would do it:

NSArray* newArray = [NSArray arrayWithArray:oldArray]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!