开发者

Fastest way to find a contact matching name?

开发者 https://www.devze.com 2023-04-02 05:02 出处:网络
I have a T开发者_如何学JAVAableView filled with NSArray containing NSString names of some contacts from address book, in detailTextLabel of cells some information from that contact have to be shown. F

I have a T开发者_如何学JAVAableView filled with NSArray containing NSString names of some contacts from address book, in detailTextLabel of cells some information from that contact have to be shown. For every cell, I copy all contacts from addressbook to an array, search the all_contacts array using filteredArrayUsingPredicate method to find the contact matching the name of current cell, return its RecordID, then get the information to display in detailTextLabel. But it's tooooo slow and TableView will scrolling smoothly. What is the fastest way to find a contact matching a name?


If you need to search against names a lot, can you keep track of your objects by array and dictionary, you can then use the dictionary to lookup people by name, you will what to wrap these up in a few methods or even class that keeps the two in sync.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号