UIView as dictionary key?

后端 未结 3 865
無奈伤痛
無奈伤痛 2021-02-11 20:57

I want to have a NSDictionary that maps from UIViews to something else.

However, since UIViews do not implement the NSCopying pro

3条回答
  •  清酒与你
    2021-02-11 21:53

    You can use an NSValue holding the pointer to the UIView and use this as key. NSValues are copyable. but, if the view is destroyed, the NSValue will hold a junk pointer.

提交回复
热议问题