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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:47:35+00:00 2026-06-09T15:47:35+00:00

I am trying to decide on a design pattern. I have an app where

  • 0

I am trying to decide on a design pattern. I have an app where the user adds an entry to a Core Data database. They also should have the ability to edit that entry at a later time as well. Both views basically show the same data, only one is for editing what has already been added.

I am not sure if I should have two very similar separate view controllers or if I should use some kind of inheritance to set this up, or if there is some other idea that I’m not thinking of.

I appreciate your input.

  • 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-09T15:47:36+00:00Added an answer on June 9, 2026 at 3:47 pm

    I have encountered a similar item to solve and ended up going with the using the same UIViewController to do both operations. Both use cases are fundamentally the same: a user enters information and then saves. The validation of the data is the same, saving is the same, the presentation is the same. They only vary on whether your model object already exists or not. Consider the following example:

    .h file:

    @interface WHItemViewController : UITableViewController
    
    //  This is the only attribute we really need to expose in our header
    //  so that the presenting view controller can set the model object when editing
    @property (nontatomic, retain) WHItem* item;
    
    @end
    

    .m file:

    @interface WHItemViewController()
    
    // Other 'private' properties and methods
    
    - (void)didSelectSaveButton:(id)sender;
    
    @end
    
    @implementation WHItemViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        if (self.item) { // setup the UI with the model object, if present.
            self.fooText.text = self.item.foo;
            self.barText.text = self.item.bar;
            self.bazText.text = self.item.baz;
        }
    }
    
    - (void)didSelectSaveButton:(id)sender {
        if (!self.item) {
            WHItem* item = nil;
    
            //  create a new instance from your managed object context 
            //  and set it to the item property
    
            self.item = item;
        }
    
        self.item.foo = self.fooText.text;
        self.item.bar = self.barText.text;
        self.item.baz = self.bazText.text
    
        NSError* error = nil;
        [WHDataAccess sharedInstance].managedObjectContext save:&error];
    
        // Error handling, etc.
    }
    
    //  Other methods
    
    @end
    

    The sole purpose of this view controller is to create presentation for editing and saving model object data.

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

Sidebar

Related Questions

I'm trying to decide on a database design. More specifically, this is a sub-part
I'm trying to decide how to design a Netty app with what I think
I am trying to decide which would be the best data warehouse type design.
This is a design question. I'm trying to decide between 2 implementations. In order
I'm trying to decide whether I should create a simple StackPanel with Buttons on
I am trying to decide on which approach to take in a database I
I'm trying to implement what I think is a fairly simple design. I have
So I have an interesting design question regarding an app I'm developing for the
I'm currently trying to design an application and I'm having trouble trying to decide
Im currently trying to decide on a design for a TCP server where the

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.