Question

I have currently the following data model:

An Entry Object that has an attribute startDate and an Relationship to one Month Object

A Month object that keeps n Entries an has some other attributes

The month Relationship will be assigned on creation of the Entry Object depending on the startDate.

Now the following problems occurs: The user can change the start date and this can affect the month relationship. Whats the correct way to update the relationship when the startDate changes.

Is -(BOOL)validateStartDate:(id *)ioValue error:(NSError **)error in the NSManagedObject the right place to do this?

If yes how can I get the other months available in the current context? I think fetching objects from context in an NSManagedObject is not a good idea

Was it helpful?

Solution

I see no other way to do it. Just fetch all the months with no predicate, figure out which one you need and set the relationship, or if you can get exactly the month you need by setting the NSFetchRequest's predicate, it would be even better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top