I have a to-one relationship in my data model with Core Data. I'm trying to set the value of the relationship but Core Data keeps thinking that it's nil. The "creatorUser" relationship is not optional, so when I go to save my managed object context, Core Data gives errors because it thinks the "creatorUser" is nil.
Any help would be greatly advised.
NSManagedObject *teamManagedObject = [NSEntityDescription insertNewObjectForEntityForName:@"DCTeam" inManagedObjectContext:_managedObjectContext];
// Creator Properties
NSManagedObject *creator = [self userForID:[ticketInfo objectForKey:@"userid"]];
if (!creator) {
creator = [NSEntityDescription insertNewObjectForEntityForName:@"DCUser" inManagedObjectContext:_managedObjectContext];
[creator setValue:[personInfo objectForKey:@"userid"] forKey:@"userid"];
[creator setValue:[personInfo objectForKey:@"creatorName"] forKey:@"name"];
}
[teamManagedObject setValue:creator forKey:@"creatorUser"];