In my app, I have a NSDictionary
whose keys should be instances of a subclass of NSManagedObject
.
The problem, however, is that NSMa
I had a similar problem, in which I needed to bundle several entities with additional data for each, and initially tried:
@{entity1:data1, @entity2:data2, @entity3:data3}
this didn't work for the reason above (NSCopying), so I did:
@[
@{@"entity":entity1, @"data":data1},
@{@"entity":entity2, @"data":data2},
@{@"entity":entity3, @"data":data3}
]
But this solution makes sense only if you don't need dictionary style access to these entities or are happy to iterate to find what you need. In my case this was a packaging problem. Note that if you pass these entities around the NSManagedObjectContext need to be the same to use them.