Search for Index

Is there a way to find the index of a row in a table view without having to loop through the entire list?

Let’s say I want to programmically select a row but I only know one of its keys and I don’t know which index that is on.

Here is how I am doing it now with a repeat loop:

I thought about doing a NSPredicate filter, but that seems to actually filter the list down to a smaller list. All I need is the index.

I’m not sure I understand the question. All the rows should contain the same keys (they represent the columns, in effect) – it’s the values that differ. Are you saying you want to select a row that has a particular value for a particular key?

correct.

I think I can do it with NSPredicate and indexOfObjectPassingTest.

You could probably also use valueForKey and then indexOfObjectEqualTo (from memory --something like that) on the result.

Shane,

Thank you. I will check that out; it looks like that might be simplier. Out of curiosity might explore both methods.

Cheers,

gt

The latter should probably just be indexOfObject:.