• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data one to many insert question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data one to many insert question


  • Subject: Re: Core Data one to many insert question
  • From: Pablo Pons Bordes <email@hidden>
  • Date: Fri, 14 Jan 2011 13:07:44 +0000

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

  • Follow-Ups:
    • Re: Core Data one to many insert question
      • From: Philip Vallone <email@hidden>
References: 
 >Core Data one to many insert question (From: Philip Vallone <email@hidden>)

  • Prev by Date: Re: Determining whether a dictionary is mutable or not
  • Next by Date: Re: Core Data one to many insert question
  • Previous by thread: Core Data one to many insert question
  • Next by thread: Re: Core Data one to many insert question
  • Index(es):
    • Date
    • Thread