NSManagedObject as NSDictionary key?

前端 未结 4 1688
孤街浪徒
孤街浪徒 2021-01-01 15:30

In my app, I have a NSDictionary whose keys should be instances of a subclass of NSManagedObject.

The problem, however, is that NSMa

4条回答
  •  生来不讨喜
    2021-01-01 15:51

    Could you create a wrapper class, that contains a reference to the instance of NSManagedObject that you want to use as a dictionary key? You could then make this wrapper class implement NSCopying, along with a hash method (perhaps just calling the NSManagedObject's hash method), and use this wrapper as the dictionary key.

提交回复
热议问题