I am building an autocomplete feature for an ios application. After getting all the contacts in CFArrayRef. What would be the most efficient way to retrieve the contacts by email and phone number given a search string.
Asked
Active
Viewed 546 times
2 Answers
0
Have you searched on SO? Like here? Or looked on Apple's documentation?
After getting all contacts you can compare the strings with compare:
or rangeOfString:
.
0
If I were doing this, just as the user decided to enter something where I might need this, I would essentially create an NSArray of dictionaries for each contact (coverting the address objects into full fledged Cocoa objects).
Then as the user types, you can use nested "enumerate" block methods provided by both NSArray and NSDictionary to rapidly find the appropriate entry.

David H
- 40,852
- 12
- 92
- 138
-
could you provide some code on how exactly to search once you have the array of people objects. – VBK Aug 05 '12 at 06:09