ios - How to see if object is contained in an embedded NSArray, then grab the other items in the set -


i have nsarray contains many nsarrays, each containing pair of nsstrings such following: [["a", "b"], ["u", "a"], ["x", "y"], ...], , interested first checking see if contains particular object, , grabbing other paired object , putting in array. example, if checking "a" in above array, result array contain ["b", "u"]

i know how iterate on each array, trouble deciding how grab paired object inside array... thanks!

for (nsarray *innerarray in outerarray){     if ([innerarray containsobject: @"a"]){        //how extract other object , save array?     } } 

if you're sure data have structure describe, can use fact inner array have 2 element - index of "other" element 1-indexofyourelement:

for (nsarray *innerarray in outerarray){     nsuinteger ix = [innerarray indexofobject:@"a"];     if (ix!=nsnotfound){        id objecttoadd = innerarray[1-ix];        //     } } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -