Note that there are some explanatory texts on larger screens.

plurals
  1. POaddObject for one/many-to-many relationships in core data for iPhone
    primarykey
    data
    text
    <p>I have the following 2 Entity’s in my xcdatamodel:</p> <ol> <li><p>Matrix 1.1 Attributes Name 1.2 Relationships MatrixToProcess The Destination is: Process The Inverse is: ProcessToMatrix The To-Many Relationship is checked The Delete Rule is Cascade</p></li> <li><p>Process 2.1 Attributes Name 2.2 Relationships ProcessToMatrix The Destination is: Matrix The Inverse is: MatrixToProcess The To-Many Relationship is not checked The Delete Rule is Nullify</p></li> </ol> <p>I can successfully add a new Matrix, which is added and shows up correctly in the UITableView.</p> <p>I can successfully add a new Process, however, All necessary information is added to the database with the EXCEPTION of the Z_PK value from the Matrix table. i.e. The sqlite database in the iPhone simulator will create the new Process Name, but does NOT enter any information into the ZPROCESSTOMATRIX column. If I manually insert the associated Matrix Name Z_PK value, everything works.</p> <p>I am struggling with. don't fully understand how to add the addObject under the Process *newProcess = [NSEntityDescription insertNewObjectForEntityForName:@"Process" inManagedObjectContext:self.managedObjectContext];. This is the code I am using:</p> <pre><code>- (void)addProcess:(id)sender { ProcessAddViewController *addController = [[ProcessAddViewController alloc] initWithNibName:@"ProcessAddView" bundle:nil]; addController.delegate = self; Process *newProcess = [NSEntityDescription insertNewObjectForEntityForName:@"Process" inManagedObjectContext:self.managedObjectContext]; addController.process = newProcess; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; [self presentModalViewController:navigationController animated:YES]; [navigationController release]; [addController release]; } - (void)processAddViewController:(ProcessAddViewController *)processAddViewController didAddProcess:(Process *)process { if (process) { [self showProcess:process animated:NO]; } [self dismissModalViewControllerAnimated:YES]; } - (void)showProcess:(Process *)process animated:(BOOL)animated { RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStyleGrouped]; rootViewController.managedObjectContext = self.managedObjectContext; if(entitySearchPredicate == nil) { NSMutableArray* mutableFetchResults = [CoreDataHelper getObjectsFromContext:self.entityName :@"displayOrder" :YES :managedObjectContext]; [self setEntityArray:mutableFetchResults]; [mutableFetchResults release]; } else { NSMutableArray* mutableFetchResults = [CoreDataHelper searchObjectsInContext:self.entityName :entitySearchPredicate :@"displayOrder" :YES :managedObjectContext]; [self setEntityArray:mutableFetchResults]; [mutableFetchResults release]; } [rootViewController release]; } </code></pre> <p>Any help and/or direction will be greatly appreciated.</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.
 

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