How to see if object is contained in an embedded NSArray, then grab the
other items in the set
I currently have a NSArray which contains many NSArrays, each containing a
pair of NSStrings such like the following: [["A", "B"], ["U", "A"], ["X",
"Y"], ...], and I am interested first checking to see if it contains a
particular object, and then grabbing the other paired object and putting
it in an array. For example, if I am checking for "A" in the above array,
the result array would contain ["B", "U"]
I know how to iterate over each array, but am trouble deciding how to grab
the paired object inside the array... thanks!
for (NSArray *innerArray in outerArray){
if ([innerArray containsObject: @"A"]){
//how to extract the other object and save it to an array?
}
}
No comments:
Post a Comment