Is there any ordered dictionary collection in IOS

2019-08-07 13:48发布

问题:

My issue is I am using the table data source from the dictionary. This dictionary contains more than 20 elements in it.

I need to search the element present in the dictionary and I need to scroll that element to a visible cell.

My issue is I found the element, but it is out of the visible area. I need to scroll that to a visible area.

How can I get the index?

回答1:

Short answer? Nope. I know the feeling though, which lead me to...

Longer answer? Yes-ish? My search a little while back brought me to this lovely little page. The guy provides a nice, neat little class for an ordered dictionary. I suggest reading the full article, it explains things nicely.

The basic gist is that it maintains both an NSMutableArray and an NSMutableDictionary at the same time, using the array for indices, and the dictionary for keys. Quite simple, really.