Frost
Frost

Reputation: 3896

Is there a Cocoa equivalent of map from C++?

I really love map in C++, it's fast and easy to program.

Is there anything similar in Cocoa?

I know I can mix C++ and obj-c together, but I'd rather use a more obj-c way to program :)

Thanks!!

Upvotes: 3

Views: 1877

Answers (2)

Leibowitzn
Leibowitzn

Reputation: 830

You might also want to use NSMapTable. It's main benefit is that it won't copy the key the way NSDictionary does.

Upvotes: 2

Alan
Alan

Reputation: 46833

Try NSDictionary / NSMutableDictionary.

As an aside, you should use a map/dictionary when it's the best data structure choice, not just because it's easy and fast (although programmer time is expensive, proper structure choice will help create a better overall design). Maps make sense when you need to quickly look up values, and you don't care if they are stored in a sorted order.

Upvotes: 4

Related Questions