1

I have an array of dictionaries containing some values and keys.suppose keys k1,k2,k3,k4 etc... from this array I need to find object for key k1 for which I know the object of key k3 of the same dictionary. Is there any method without using iteration that means by using predicates or keyvalue coding(KVC)

Johnykutty
  • 12,091
  • 13
  • 59
  • 100

2 Answers2

1

This is not possible without searching the array, since k3 doesn't have any way of knowing it is used as a key in one of the dictionaries. In fact, it could be used as a key in more than one dictionary.

waldrumpus
  • 2,540
  • 18
  • 44
  • not with that key the object of that key. Its unique because its an id – Johnykutty Sep 21 '12 at 10:35
  • @Johnykutty In your case, the objects may be unique, but in general, they need not be. Thus, there is no language mechanism to solve your problem. – waldrumpus Sep 21 '12 at 10:47
0

No, you'll need to iterate over the array, check for key k3and return k1if you've found a match.

Asciiom
  • 9,867
  • 7
  • 38
  • 57