OK, super-old question, but here's how I'd be solving it now.
Not all relationships have to be filled. Keep your inverse (two-way) relationships but you don't necessarily have to link them.
+ (void)createRestaurantWithCompletion:(void (^)(BOOL, NSError *))completion {
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
Restaurant *localRestaurant;
LatitudeLongitude *localLatLng1;
LatitudeLongitude *localLatLng2;
restaurant = [Restaurant MR_createInContext:localContext];
localLatLng1 = [LatitudeLongitude MR_createInContext:localContext];
localLatLng2 = [LatitudeLongitude MR_createInContext:localContext];
restaurant.latLng = localLatLng1;
} completion:completion];
}
By the time completion
is called, both localLatLng1
and localLatLng2
exist, one is linked to a restaurant, one isn't.
Of course this method makes no sense in this form, it's just to prove the point that you can create objects without having to satisfy their relationships.
Z.