objective c - How to make an array by jumping over every 1 index -


hi there way make array jumping on every 1 index lets have array objects this:

nsarray *array =[nsarray alloc] initwithobjects:@"id",@"name",@"id",@"name",@"id",@"name".. 

... , on, can make array taking id objects and/or names. i'm stuck in this, want achieve want id's in tableview subtitle, , names on tableview title. suggestions?

edit: everybody, got answer, couldn't go though nsdictionary because, i'm getting objects .php. anyways thank you!

if want ids , names separated in 2 different arrays, iterate through original array, , use mod operator this.-

nsarray *array = [[nsarray alloc] initwithobjects:@"id",@"name",@"id",@"name",@"id",@"name", nil]; nsmutablearray *ids = [[nsmutablearray alloc] init]; nsmutablearray *names = [[nsmutablearray alloc] init];  (int = 0; < array.count; ++) {     if (i % 2 == 0) {         [ids addobject:[array objectatindex:i]];     } else {         [names addobject:[array objectatindex:i]];     } } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -