Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a few options:<br> 1. You can use <code>add&lt;Key&gt;Object:</code> on a NSManagedObject: </p> <pre><code>NSManagedObject *flightBoard = [NSEntityDescription insertNewObjectForEntityForName:@"FlightDepartureBoard" inManagedObjectContext:self.managedObjectContext]; NSManagedObject *details = [NSEntityDescription insertNewObjectForEntityForName:@"Flight_Details" inManagedObjectContext:self.managedObjectContext]; [flightBoard addCurrent_flightsObject:details]; </code></pre> <p>Although you will get a compiler warning unless you define the accessors in a category: </p> <pre><code>@interface NSManagedObject (Current_flightsAccessors) - (void)addCurrent_flightsObject:(NSManagedObject *)value; - (void)removeCurrent_flightsObject:(NSManagedObject *)value; - (void)addCurrent_flights:(NSSet *)value; - (void)removeCurrent_flights:(NSSet *)value; @end </code></pre> <p>2. Subclass. You can generate class files from your model which will include accessors for the to-many relationships:</p> <p><strong>FlightDepartureBoard.h:</strong> </p> <pre><code>#import &lt;CoreData/CoreData.h&gt; @class Flight_Details; @interface FlightDepartureBoard : NSManagedObject { } @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSString * from_airport; @property (nonatomic, retain) NSString * to_airport; @interface FlightDepartureBoard (CoreDataGeneratedAccessors) - (void)addCurrent_flightsObject:(Flight_Details *)value; - (void)removeCurrent_flightsObject:(Flight_Details *)value; - (void)addCurrent_flights:(NSSet *)value; - (void)removeCurrent_flights:(NSSet *)value; @end </code></pre> <p><strong>FlightDepartureBoard.m:</strong> </p> <pre><code>#import "FlightDepartureBoard.h" #import "Flight_Details.h" @implementation FlightDepartureBoard @dynamic name; @dynamic from_airport; @dynamic to_airport; @dynamic current_flights; @end </code></pre> <p>3. You can get the mutable set and modify it using mutableSetValueForKey:. For example: </p> <pre><code>NSManagedObject *flightBoard = [NSEntityDescription insertNewObjectForEntityForName:@"FlightDepartureBoard" inManagedObjectContext:self.managedObjectContext]; NSManagedObject *details = [NSEntityDescription insertNewObjectForEntityForName:@"Flight_Details" inManagedObjectContext:self.managedObjectContext]; NSMutableSet *flights = [flightBoard mutableSetValueForKey:@"current_flights"]; [flights addObject:details]; </code></pre> <p>For more information, check out <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreData/" rel="nofollow noreferrer">Managed Object Accessor Methods</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload