0
我有這個數組,我需要所有的第一個元素。如何讀取IOS中的多個陣列中的第一項
我只能讀一個與此
vc.ArrayListaFotos = [[listaImagens objectAtIndex:(indexPath.row * 3)] valueForKey:@"Caminho"];
但我不能閱讀其他人的內部陣列1,2,3第一itens ...
有人可以幫助我請 ?
我有這個數組,我需要所有的第一個元素。如何讀取IOS中的多個陣列中的第一項
我只能讀一個與此
vc.ArrayListaFotos = [[listaImagens objectAtIndex:(indexPath.row * 3)] valueForKey:@"Caminho"];
但我不能閱讀其他人的內部陣列1,2,3第一itens ...
有人可以幫助我請 ?
您正在使用錯誤的參考。你應該這樣做:
NSMutableArray *arrayDeImagensParaOProdutoSelecionado = [NSMutableArray arrayWithObjects:nil];
for (NSArray *tempArray in listaImagens) {
if ([[NSString stringWithFormat:@"%@", [tempArray valueForKey:@"idProduto"]] isEqualToString:[NSString stringWithFormat:@"%@", [[produtos objectAtIndex:(indexPath.row * 3)] valueForKey:@"id"]]]) {
[arrayDeImagensParaOProdutoSelecionado addObject:tempArray];
}
}
希望它有幫助。
for(NSArray *innerArray in outerArray) {
NSObject *firstObject = [innerArray firstObject];
// do whatever you need to with firstObject
NSLog(@"%@",firstObject);
}
它是一個數組的數組,你需要所有嵌套數組的第一個對象? – nhgrif
只是做循環? for(int x = 0; x
stepik21
@ stepik21'forin'好得多。看到我的答案。 ;) – nhgrif