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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:34:28+00:00 2026-05-27T19:34:28+00:00

I present a UINavigationController as a ModalViewController. The UINavigationViewController handles a segue of (navigated)

  • 0

I present a UINavigationController as a ModalViewController. The UINavigationViewController handles a segue of (navigated) UIViewControllers. With my first ModalViewController (MVC) I want to create a new instance of my NSObject which has several properties. This works.

Now in every VC I have a slider to change one of the several properties of my object. At the last VC I want to save the object.

I’m using CoreData (which already works when I work with all of the properties in one VC).

Is there an easy way to achieve this?

(I’m also using NSNotificationCenter.)

EDIT:

  • In MVC1 I send a NSNotification to DetailTableViewController by pressing Next in my UINavigationBar. MVC1 pushes to MVC2.
  • When DTVC receives the NSNotification it does self insertNewObject: (standard Apple CoreData method) This methods works, I see a new instance of the object in my UITableView after dismissing the MVControllers.

  • MVC2 has an UISlider which value I want to store in my object. So I did #import "Object.h", @property (nonatomic, weak) Object * detailItem, @sythesize detailItem and stored a certain value using detailItem.property = NSNumber initWithInt etc.. I press Next. MVC2 pushes to MVC3.

  • MVC3 has also #imported ... and @property .... It does in viewDidLoad: NSLog(@"%i", [detailItem.property intValue]); and shows 0 instead of myInteger. What am I doing wrong?

EDIT:

Which changes are necessary to make this piece of code work?

In ModalViewController

- (void)setDetailItem:(Object *)newDetailItem
{
if (_detailItem != newDetailItem) {
    _detailItem = newDetailItem;

    // Update the view.
    [self configureView];
}
}

In MasterViewController

- (void)insertNewObject
{
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];

[newManagedObject setValue:@"New Object" forKey:@"name"];
[self.firstAssistantViewController setDetailItem:(Object *)newManagedObject];

// Save the context.
NSError *error = nil;
if (![context save:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}
}
  • 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-27T19:34:29+00:00Added an answer on May 27, 2026 at 7:34 pm

    Pass the new object along as a property to the other modal view controllers. The managed object contains a reference to the managed object context so you can save at any point.

    So, for each modal view controller:

    .h:

    @property (nonatomic,weak) Object* newManagedObject;
    

    .m:

    @synthesize newManagedObject;
    

    And before you present each view controller:

    modalViewControllerX.newManagedObject = newManagedObject;
    

    Configure your UI (set the slider values etc) on viewWillAppear: like so:

    self.slider.value = self.newManagedObject.property;
    

    And update the managed object using the reverse when the slider value changes:

    self.newManagedObject.property = self.slider.value;
    

    In the final view controller, if you wish to save there, you can do this:

    NSError *error = nil;
    [self.newManagedObject.managedObjectContext save:&error];
    // Your own error checking goes here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to present a wizard once, the first time my windows forms application
If you have a UINavigationController's UIViewController present a UITableViewController (TVC) modally, is there a
I create & present modally an UITableViewController(say Table2) class from another UITableViewController class(say Table1)
If I push view controllers and/or present modal view controllers on a UINavigationController ,
I have the following code in application didFinishLaunchingWithOptions where I want to present a
I have a view that is UIViewController (root) that handles ads and a UINavigationController
From a tableview I want to present a MFMailComposeViewController. I don't want to use
In my app, I use a UINavigationController to switch between many different UIViewControllers. The
I'm showing UINavigationController modally. For the root view controller, I don't want to show
I present a modalViewController that is actually a navigation controller with one view, and

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.