Let's say I have two objects: Articles and Categories with many relationships between them. For this example, all necessary categories have already been added to the data warehouse. When navigating through data that contains changes for articles, there is information on the correlation of categories that must be saved.
I planned to use the method -setValuein the class Articleto establish such relationships:
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
if([key isEqualToString:@"categories"]){
NSLog(@"trying to set categories...");
}
}
The problem is that valueit is not Category, but just a string (or an array of strings) containing the category heading. Of course, I could do a search in this method for each category and assign it, but this seems ineffective in processing a number of articles at once. Another option is to fill in an array of all possible categories and just filter, but my question is where to store this array? Should this be a cool method on Article? Is there a way to pass additional data to a method -setValue? Is there any other, better option for establishing relationships that I don't think about?
Thank you for your help.
source
share