Re: Core Data one to many insert question
Re: Core Data one to many insert question
- Subject: Re: Core Data one to many insert question
- From: Philip Vallone <email@hidden>
- Date: Fri, 14 Jan 2011 08:41:03 -0500
Thanks. I had used X-code to create the subclasses. I see that it created the required methods for adding the "children". Thanks for the help. If I have any issues, I'll post a new question.
Regards,
Phil
On Jan 14, 2011, at 8:07 AM, Pablo Pons Bordes <email@hidden> wrote:
> You need to declare some method that core date implement for you, for this situations, to make your life easier XCode help you to declare it and declare those custom class file declarations:
>
> - At your Core Date model select the entities you want to make a custom class.
> - go to Menu File>New File...
> - At Cocoa Class or (Cocoa Touch Class, depend what you are doing) you find a New File Type, Managed Object Class.
> - Select it and create the classes.
>
> Then you will see is really easy.
>
> NOTE: When you do this the old implementation you have will me deleted, refactor it before you make the classes if you don't want to lost what you did before.
>
> Pablo Pons
>
>
>
>
>
>
> El 14/01/2011, a las 12:53, Philip Vallone escribió:
>
>>
>> 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
>
_______________________________________________
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