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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:56:21+00:00 2026-05-12T07:56:21+00:00

I have application with following design: Table View that lists documents. And ViewController where

  • 0

I have application with following design:
Table View that lists documents.
And ViewController where document is edited.

When editing the document I want to use a copy of object so in case user press Cancel I just throw away the copy. If user selected Save I copy modified document to original.
(I can’t have all document’s fields as properties in viewController because there are too many of them).

Table View controller:

SelectedRowAtIndex {
  document= [documentsArray objectAtIndex:indexPath.row];
  viewController.assignedDocuemnt= document;
}

Then I have View controller class where the item is modified:

@interface
@property (nonatomic,retain) Document *asignedDocument;
@property (nonatomic,retain) Document *editedDocument;

viewDidLoad{
   editedDocument= [assignedDocuemnt copy];
}


IBAction save {
   assignedDocument=editedDocument;
}

My problem is that original document in documentsArray is not updated with edited version.
What did I miss?

  • 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-12T07:56:22+00:00Added an answer on May 12, 2026 at 7:56 am

    You’re copying the value and then assigning the reference of the copy back over a reference to the original. That’s definitely not going to work.

    First, keep track of which document they’re adding in the table view’s viewcontroller.

    Then add a handler for replacing the selected document with another to the table view’s viewcontroller:

    - (void)replaceSelectedDocument:(Document*)newDoc {
        [documents replaceObjectAtIndex: editingIndex
                             withObject: newDoc];
    }
    

    To save, call the table view controller’s new message from the editor view controller with something like:

    [tableViewController replaceSelectedDocument: editedDocument];
    

    A better way to do this would be to modify your editor view controller to take a target and action instead of calling back to the table view controller explicitly. When you want to save, call the action:

    [target performSelector: action withObject: editedDocument];
    

    But that’s another bump on the learning curve that you probably don’t need to get over today.

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

Sidebar

Related Questions

I have an application that is made up of the following: A central database
I have a C# application that includes the following code: string file = relativePath.txt;
I have a web application that comprises the following: A web project (with a
I have a winforms application that is doing the following: on each query: Db
We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
Is there any name for the following DB table design: Basically we have generic
I have the following application which replicates an issue I'm having in a larger
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I have a large application (~50 modules) using a structure similar to the following:

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.