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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:50:18+00:00 2026-05-27T14:50:18+00:00

I’ve got a sublass of UITableViewController which I use to add a new data

  • 0

I’ve got a sublass of UITableViewController which I use to add a new data for a new cell within another Table. That means, I’ve got a “Cancel” and a “Save” button at the top to save the data and get back to the table where to add the new object into. I show the adding controller modally.

My problem is though that I don’t know how to get the data from the user input cells of the tableView in my UITableViewController subclass to save them in my CoreData file.

Here’s the code how I try it – but at the console I just get (nil) for the persons name:

- (void)save
{

NSLog(@"Saving ...");
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];


UITableViewCell *cell = [self tableView:[self tableView] cellForRowAtIndexPath:indexPath];
NSString *personName = [[cell textField] text];

NSLog(@"New Person: %@", personName);

// Do saving with Core Data and updating here.

[self dismissModalViewControllerAnimated:YES];
}

I guess you will also need the following method to understand the problem:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
static NSString *CellIdentifier = @"Cell";

EditableDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[EditableDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

cell.accessoryType = UITableViewCellAccessoryNone;

if (indexPath.section == 0) {
    [cell.textField setPlaceholder:@"Name"];
} else {
    switch (indexPath.row) {
        case 0:
            [cell.textField setPlaceholder:@"Birth Year"];
            break;
        case 1: 
            [cell.textField setPlaceholder:@"Weight in kg"];
            break;
        case 2:
            [cell.textField setPlaceholder:@"Height in cm"];
            break;
        case 3:
            [cell.textField setPlaceholder:@"Sex"];
            break;
        default:
            break;
    }
}

return cell;
}

I really can’t find the failure. In my understanding it should work this way … but it doesn’t. Could anyone please help?

  • 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-27T14:50:18+00:00Added an answer on May 27, 2026 at 2:50 pm

    Don’t call your table view datasource method to get the value in the cell. Get it directly from the table view instead.

    Instead of this:

    UITableViewCell *cell = [self tableView:[self tableView] cellForRowAtIndexPath:indexPath];
    

    Do this:

    UITableViewCell *cell = [[self tableView] cellForRowAtIndexPath:indexPath];
    

    Doing it the way you are doing is essentially recreating the cell and so losing the value you have entered. The datasource method is only meant to be called by the table to work out what to display.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6

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.