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

  • Home
  • SEARCH
  • 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 8816873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:43:12+00:00 2026-06-14T04:43:12+00:00

In my app, I have my master view controller which displays all my coredata

  • 0

In my app, I have my master view controller which displays all my coredata objects.

When the user adds an object this runs and the next detail view opens to enter details for the new object:

-(IBAction)addPerson:(id)sender
{
    Person *p = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:managedObjectContext];
    PersonDetailViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"PersonDetail"];
    vc.managedObjectContext = fetchedResultsController.managedObjectContext;
    vc.person = p;
    vc.isNewPerson = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

Now I have a delete button in the detail view which calls this:

[managedObjectContext deleteObject:person];
    NSError *err;
    if (![managedObjectContext save:&err])
    {
        // Update to handle the error appropriately.
        NSLog(@"Unresolved error %@, %@", err, [err userInfo]);
        exit(-1);  // Fail
    }

This is how I currently cancel a new coredata object. However I am having issues with it.

How would you recommend I best cancel the creation of a new object? Create and delete, or never create it until confirmed? I’m unsure.

  • 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-14T04:43:13+00:00Added an answer on June 14, 2026 at 4:43 am

    I’d actually never create the managed object until confirmed!

    But in the first place I’d rewrite the PersonDetailViewController to not have a dependency to the Person entity at all (loose coupling). Instead I’d define properties in your PersonDetailViewController for the various attributes of the Person object you like to set/edit and then handle the creation of the Person managed object in a save delegate method or so. With this approach you could also cancel the creation use-case half through, without the need for creation of a new managed object etc.

    For better illustration, the delegate method would look somewhat like this:

    - (void) personDidSave: (PersonDetailViewController*) controller {
            // Create a new Person object with the values from the controller
            // and add persist it to core data
            Person *p = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:managedObjectContext];
            p.name = controller.name;
            p.surname= controller.surname; 
            // etc.
    
            // save to core data
    
            // Refresh the table or whatever view
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iPhone Core Data app I have it configured in a master-detail view
I have this problem with my view-controller relation. This is the controller: <?php class
This question is in reference to an iPhone app which uses Xcode's Master Detail
I have a master-detail controller for my app. The master controller is a UITabBarController
I have a 3.0.7 app using active scaffold from github vhochstein/master. I am using
This is a continuation of the question here: JBoss - does app have to
we have app hosted on google app engine for java. In this app we
I'm writing an iPhone app. Starting from a view controller in a navigation stack
I have a table view. I want my app to work like the Contacts
I believe I have set up our MVC app to use [HandleError] properly. This

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.