• 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
One-to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

One-to-many relationship


  • Subject: One-to-many relationship
  • From: Norio Ota <email@hidden>
  • Date: Thu, 27 Sep 2007 14:23:16 +0900

Hi guys,

I have just got how to set "many" relationship by using addObject:, but don't know how to set "one" relationship.
I went see DepartmentAndEmploee sample, but I still don't understand.


Would you tell me which API is the one I should use? Or I don't need to do anything for that?

Entity: Employ
  name(attribute)
  department(one relationship)

Entity: Department
  dept_name(attribute)
  employees(many relationship)


The following code is what I wrote for a Department object adding new employee object.


NSMutableSet * aSet = [deptObject mutableSetValueForKey:@"employees"];
for (i = 0; i < maxnum; ++i )
{
id iEmployee = [NSEntityDescription insertNewObjectForEntityForName:@"Employee" inManagedObjectContext:context];


  [aSet addObject:iEmployee];
}

But how should I connect the department object to 'department' of Employ object.

Is the following code OK?

[iEmployee setValue:deptObject forKey:@"department"];

Thank you for reading this poor explanation.

Norio Ota
_______________________________________________

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: One-to-many relationship
      • From: mmalc crawford <email@hidden>
References: 
 >Cocoa won't draw CMYK jpeg (From: Robert Clair <email@hidden>)
 >Re: Cocoa won't draw CMYK jpeg (From: Scott Thompson <email@hidden>)
 >Re: Cocoa won't draw CMYK jpeg (From: Robert Clair <email@hidden>)
 >Re: Cocoa won't draw CMYK jpeg (From: Scott Thompson <email@hidden>)
 >Re: Cocoa won't draw CMYK jpeg (From: Robert Clair <email@hidden>)
 >Re: Cocoa won't draw CMYK jpeg (From: Scott Thompson <email@hidden>)

  • Prev by Date: Re: Convenience Methods
  • Next by Date: Re: One-to-many relationship
  • Previous by thread: Re: Cocoa won't draw CMYK jpeg [SOLVED]
  • Next by thread: Re: One-to-many relationship
  • Index(es):
    • Date
    • Thread