Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8675401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:56:26+00:00 2026-06-12T19:56:26+00:00

I created a core data model that has three entities called Customer, Form1 and

  • 0

I created a core data model that has three entities called Customer, Form1 and Form2. I’ve set up inverse relationships from Customer to form1 and form2 and vise versa. So when a new customer is created form1 and form2 need to be created for that customer. The problem that I am having is accessing the correct form1 or form2 for each customer after a customer has been perviously deleted. So how do i properly add and delete the object from all three entities. Let me know If I am doing everything in the correct way because I’ve never worked with multiple entities before and in an uitableview. Any help would be great!

-(void) viewDidLoad  
{
// Generate a fetch request for reading from the database and set its entity property
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName: @"Customer" inManagedObjectContext: managedObjectContext];
request.entity = entity;
[entity release];

// Perform the actual fetch from the permanent store and initialize the menuItems array with the results
NSError *error = nil;

customerArray = [[managedObjectContext executeFetchRequest: request error: &error] 

[request release];
}




- (void) addItem
{
// Insert a new record in the database
Customer * customerItem = [NSEntityDescription insertNewObjectForEntityForName: @"Customer" inManagedObjectContext: managedObjectContext];
NSError *error = nil;

// Insert a new item in the table's data source
[customerArray insertObject: customerItem atIndex: 0];

[NSEntityDescription insertNewObjectForEntityForName: @"Form1" inManagedObjectContext: managedObjectContext];

[NSEntityDescription insertNewObjectForEntityForName: @"Form2" inManagedObjectContext: managedObjectContext];
[managedObjectContext save: &error];

// Insert a new row in the table
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: 0 inSection: 0];
[table insertRowsAtIndexPaths: [NSArray arrayWithObject: indexPath] withRowAnimation: UITableViewRowAnimationFade];
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
{
    // Delete item from the context and save the context. This removes the item from the permanent store.
    [managedObjectContext deleteObject: [customerArray objectAtIndex: indexPath.row]];
    NSError *error = nil;
    [managedObjectContext save: &error];

    // Remove the item from the table's data source array
    [customerArray removeObjectAtIndex: indexPath.row];

    // Delete the item from the table itself.
    [tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject: indexPath] withRowAnimation: YES];
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:56:27+00:00Added an answer on June 12, 2026 at 7:56 pm

    As you have made relationship from customer to form1 & form2. You can access the form1 & form2 from customer.

    Raywinderlich has a nice tutorial for demonstrating core data with relation ship, implement in the same way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a core data model that has two entities which have a
I have a core data model that has 3 entities. Driver, Manifest and Jobs.
I have a Core Data model with two entities: A and B. A has
I've noticed that in my Core Data data model, some entities are (in the
I developing an app that is read-only. The data has relationships, so I cannot
In my Core Data model, I've got a relationship called listItems which links to
I've created a project with a Core Data model in it. The application looks
I created an iPhone project using the Core Data template. Now when I try
My app uses Core Data, I used the CoreData template when created my project
There is something I dont understand in core data. I have created a NSManagedDocument,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.