I'm trying to implement the Strategy pattern using Core Data and Objective C.
To simplify, I have, say, a multilingual Text
entity, which has several attributes, such as a Date
for last saved, and a NSSString
for author etc etc. I want to add a reference to a Language
entity, which could be one of several subclasses, such as French
, Italian
and so on, holding an NSString
of text in the language of the class name. Each of the Language
subclasses can implement their own translateTo
and translateFrom
methods and the Text
instance doesn't need to worry about it. Simple Strategy Pattern.
I'm really struggling to set up this kind of relationship with Core Data, where a certain Text
entity can be set up with its own Language
implementation depending on the details of the instance.
I suppose in a nutshell, what I'm trying to do is create a "has-a" relationship, where the entity inside the Text
entity can be one of several subtypes of Language
.
Core Data is quite new to me, so if I'm completely missing the point here, or have missed something glaringly obvious, please let me know.