What is the best way to search for the index of object in multidimensional array. I tried to do it with indexOfObjectPassingTest:^BOOL(id object, NSUInteger index, BOOL *stop), but it seems that it takes two nested block like this. Is there any easier and efficient way to do this. Wandering if there is some efficient algorithm or the apple provided better method for this. How can this be achieved?
0
votes
I don't think NSArray was designed to be nested in the first place. I think you'll have to resort to using loops.
– TheAmateurProgrammer
So what data structure is better for the nested types of list of objects.
– Sandeep
It is because I am using NSArray to populate the tableview's rows and sections using multidimestional array. And now I want to retrieve a particular object from the array based on the search criteria.
– Sandeep
Generally when I want to populate a Table View, I make a new object that encapsulates all of the data in that row instead of using multidimensional arrays.
– TheAmateurProgrammer
@theAmateurProgrammer has the right approach, but it should be noted that NSArray can be nested just fine and there is nothing wrong with it.
– sosborn
1 Answers
0
votes
I think there's nothing utterly wrong with nesting arrays etc.! Did you take a look at Index Paths (And NSIndexPath class reference)?
You probably still have to code a little bit to get things done, but the methods of NSIndexPath will help you!