Core Data one to many insert question
Core Data one to many insert question
- Subject: Core Data one to many insert question
- From: Philip Vallone <email@hidden>
- Date: Fri, 14 Jan 2011 07:53:37 -0500
Hi List,
I have an Entity called "CDSites" which has a one-to-many relationship with an Entity called "CDPlacemarks". CDSites is the "Parent" and CDPlacemarks are the "Children". My Applications allows the users to create many CDSites like this:
CDSites *cdSites = [NSEntityDescription insertNewObjectForEntityForName:@"CDSites" inManagedObjectContext:context];
cdSites.prjName = self.newDetailsView.prjName;
cdSites.street = self.newDetailsView.street;
cdSites.city = self.newDetailsView.city;
cdSites.state = self.newDetailsView.prjState;
cdSites.zip = self.newDetailsView.zip;
cdSites.latitude = [NSNumber numberWithFloat:self.newDetailsView.latitude];
cdSites.longitude = [NSNumber numberWithFloat:self.newDetailsView.longitude];
NSError *error;
if (![context save:&error]) {
NSLog(@"Couldn't save: %@", [error localizedDescription]);
}
CDSites is a subclass of NSManagedObject.
This works well. My question is, I need to create the CDPlacemarks for each CDSite. How do I associate my CDPlacemarks with its "Parent" CDSites?
Thanks for the help.
Phil
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden