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 7184673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:14:59+00:00 2026-05-28T18:14:59+00:00

I am using CoreData in iOS. I have a modal AddViewController, with a RootViewController

  • 0

I am using CoreData in iOS.
I have a modal AddViewController, with a RootViewController as the delegate.

Should I do the saving of the managed object context in the root controller, or in the actual modal controller itself?

I am seeing examples of passing the data back to the rootViewController, but can’t see how this will work with data validation failures, or more complex scenarios that need the managed object context.

// AddViewController.m

- (void)save
{
  [[self delegate] controller:(id)controller didFinishWithSave:(BOOL)save withName(NSString *)name;
}

// RootViewController.m

- (void)controller:(id)controller didFinishWithSave:(BOOL)save
{
  if (save)
  {
    // save context
  }
  [self dismissModalViewControllerAnimated:YES];
}

As at the moment I am dismissing the modal using the delegate protocol.
Any advice on the best practices?
Thanks

  • 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-05-28T18:15:01+00:00Added an answer on May 28, 2026 at 6:15 pm

    I know this is a little late, but for others who come across this, I’d add a little more to Levend’s answer.

    Yes, you should have a separate manager class to handle the operations (possibly the class itself).

    I would think that if your modal needed to handle validations, before calling on the delegate, it would validate the object. If it had an error, you could handle it right there. If it passed validations, then you could pass the valid object to the delegate. Thus the delegate can make the assumption that any object that is getting passed to it is a valid one.

    As to which class you should save it, I think that is just a preference thing. But I would suggest you have a save method in the core data model itself.

    Something I came across recently is the mogenerator which is supposed to help with managing CoreData classes. I haven’t tired it yet, but it sounds good.

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

Sidebar

Related Questions

I am using two managed object contexts in my iOS app. The first context
I'm using CoreData (with SQLite as the store) in an iOS 4 iPhone application
I'm using CoreData in a multi-threaded iOS-app, and everything seems to work fine -
I am creating an iOS 5 app using Core Data. I have two entities
I'm using Core data in an iOS project. I have the data model setup
I am using CoreData in an iOS application. Everything works fine except for fields
I have an iOS 4 project using Core Data. When I design the Core
I had memory problems with an universal iOS application: CoreData was using too much
I'm using CoreData in an iOS app to save a simple list of location
I am using CoreData with iPhone SDK. I am making a notes app. I

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.