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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:35:29+00:00 2026-05-17T22:35:29+00:00

I’m trying to build a UI so the user can edit the attributes of

  • 0

I’m trying to build a UI so the user can edit the attributes of a core data entity. When the user taps the edit button, selecting a row will push the listDetailViewController, which is just a table view that displays the attributes. It uses a custom table view cell with a label and a UITextField. The listDetailViewController displays the attributes properly, and will accept text as its supposed to, but I can’t figure out how to get the user-inputted text to save.

If I’m not explaining clearly, here’s an example. I want to change the list’s name, so I tap Edit, tap the list, tap the List Name row, the keyboard pops up, I type in the new name, tap Done and it pops me back to the RVC with none of the changes saved. I’ve been banging my head on this for a few days and would love some help!

Here’s the relevant code from ListDetailViewController:

- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] 
                               initWithBarButtonSystemItem:UIBarButtonSystemItemDone 
                               target:self 
                               action:@selector(done)];
self.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];

self.tableView.allowsSelection = NO;
self.tableView.allowsSelectionDuringEditing = NO;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 3;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *DetailCellIdentifier = @"DetailCell";

ListDetailCell *cell = (ListDetailCell *)[tableView dequeueReusableCellWithIdentifier:DetailCellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"ListDetailCell" owner:self options:nil];
    cell = listDetailCell;
    self.listDetailCell = nil;

// Configure the cell...

    // list name
    if (0 == indexPath.row) {
        cell.label.text = @"List Name";
        cell.textField.text = self.selectedList.listName;
        cell.textField.placeholder = @"Name";
    }

    // Detail 1
    if (1 == indexPath.row) {
        cell.label.text = @"Detail 1";
        cell.textField.text = selectedList.detail1;
        cell.textField.placeholder = @"Detail 1";
    }

    // Detail 2
    if (2 == indexPath.row) {
        cell.label.text = @"Detail 2";
        cell.textField.text = selectedList.detail2;
        cell.textField.placeholder = @"Detail 2";
    }
}

return cell;
}


- (void)done {
[self.listDetailCell resignFirstResponder];
[self.navigationController popViewControllerAnimated:YES];
}

The ivars label and textField are declared in ListDetailCell, which is the table cell nib I mentioned earlier.

  • 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-17T22:35:29+00:00Added an answer on May 17, 2026 at 10:35 pm

    Not sure if I’ve got your problem correct or if my answer is the best method, but it’s what I did recently. I have a TableViewController and UITableView which display a series of custom cells for editing data. This is basically replicating what I’ve seen a number of other applications do to create data editing screens.

    Each of the custom cells has a UITextField. When the user finishes editing a cell, the UITextField triggers a message to a UITextFieldDelegate. So I added the UITextFieldDelegate protocol to the TableViewController and when setting up the custom cell in cellForRowAtIndexPath, I set the TableViewController as the UITextFields delegate. Then when the user finishes editing the end editing message is sent and I can then get the value from the UITextField and store it back in the managed entity object.

    I apologise, but I don’t have access to my code right now or I’d cut and paste an example for you.

    Anyway, some things to watch out for:

    • In the code for the delegate message you need to first identify the UITextField that has triggered the call. The best way to do this is to set the Tag property on the UITextField when you create the UITableCell that contains it. Then in the delegate method you can use a switch statement to select which entity field to store the value in.

    • Getting ride of the keyboard when a user taps on a non-editable area of a UITableView can be tricky. You need to store a list of objects that can have a keyboard, and when a click happens, loop through them and do the resign first responder to remove the keyboard from the display.

    • tapping a save button on the navigation bar or something else outside of the UITableView will not remove the keyboard or resign the first responder, so the delegate of the field currently being edited does not get called. You need to add code to trigger the save sequence.

    • If you have any UITextView’s they use a different delegate.

    To add the delegate you will need to do something like this (taken from your code above):

    @interface MyTableViewController : UITableViewController <UITextFieldDelegate>
    
    ....
    
        if (0 == indexPath.row) {
            cell.label.text = @"List Name";
            cell.textField.text = self.selectedList.listName;
            cell.textField.placeholder = @"Name";
    
            cell.textField.delegate = self; // Setting controller as text field delegate.
            cell.textField.tag = 1; // Really should use an enum here for clarity.
    
        }
    
    ....
    
    -(void) textFieldDidEndEditing:(UITextField *) textField {
        switch(textField.tag) {
            case 1: //Again with the enum.
                // Save field 1.
                entity.someProperty = textField.text;
            ....
        }
    }
    

    This is for dealing with a number of text fields. Another solution I found was to store the changed values in a dictionary and only update the entity when the user taps save. With my solution above, you would also have to reset the entities properties if the user cancels. So it’s horse for courses.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites 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.