ios - Get indexOfObject from Associative Array in Objective-C -


i have problem finding index of array. array looks that:

{"[name][name]", nsarray, nsarray} 

i have index of object string equals first element of associative array.

i have tried using loop, , counting integer, not work every time :/

edit: part use find index out:

int tempindex = -1, indexcount = 0;  for(nsarray *tempname in abmembers){     if([tempname[0] isequaltostring:membername]){         tempindex = indexcount;         break;     } else {         indexcount ++;     } } 

edit 2: sorry guys, found out problem was.. arrays dynamically generated, , string has compared too, , strings not same. problem. using code here should work. sorry again

i guess looking following..

nsarray *arr1 = [nsarray arraywithobjects:@"one", @"two", nil]; nsarray *arr2 = [nsarray arraywithobjects:@"three", @"four", nil];  nsarray *arr = [nsarray arraywithobjects:@"[name][name]",arr1, arr2, nil];  // loop through array for(id obj in arr) {     nslog(@"object %@ @ %d",obj,[arr indexofobject:obj]); } 

or if know object

// direct index object nslog(@"index of arr1 %d",[arr indexofobject:arr1]); nslog(@"index of string %d",[arr indexofobject:@"[name][name]"]);     

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -