开发者

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!!


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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜