Cocoa's NSDictionary: why are keys copied?

前端 未结 3 1369
小蘑菇
小蘑菇 2021-02-05 06:33

All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they\'re used in the dictionary.

I frequently

3条回答
  •  梦如初夏
    2021-02-05 07:07

    If you want to store pointers as keys then you'll need to wrap them in a NSValue object with +valueWithPointer:.

提交回复
热议问题