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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:08:44+00:00 2026-05-20T01:08:44+00:00

So I have a tableView and a detail view. I have an extra row

  • 0

So I have a tableView and a detail view. I have an extra row in my tableView to “Add” a record. When I click on the new button I send a nil object to my detail view which is the same that I use for editing an existing row. I use the following code for that:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    new = NO;
    NSUInteger row = [indexPath row];
    SavedCarDetailController *detailController = [[SavedCarDetailController alloc] initWithNibName:@"SavedCarDetailController" bundle:nil];
    if(indexPath.row >= [listOfCars count]){
         NSLog(@"New Car");
         detailController.car = nil;
        new = YES;
    } else {
        new = NO;
        detailController.car = [listOfCars objectAtIndex:row];
    }
    detailController.managedObjectContext = self.managedObjectContext;
    [self.navigationController pushViewController:detailController animated:YES];
    [detailController release];
}

When I save my core data stuff I execute this in my detailController

 - (void)viewWillDisappear:(BOOL)animated {
    NSError * e = nil;
    if(self.New){
        NSLog(@"New Car Saving");
        NSManagedObject * obj = [NSEntityDescription insertNewObjectForEntityForName:@"Cars" inManagedObjectContext: managedObjectContext];
        [obj setValue:Name.text forKey:@"name"];
        [obj setValue:Year.text forKey:@"Year"];
        [obj setValue:Notes.text forKey:@"Notes"];

    } else {
        NSLog(@"Updating exiting car");
        car.Name = Name.text;
        car.Year = Year.text;
        car.Notes = Notes.text;
}
    [managedObjectContext save:&e];
    if(e){
        NSLog(@"Error occurred, %@", e);
    }
    if(self.New){

    } else {
    //  [self.parentViewController.tableView reloadData];

    }
 }

Then I update my tableView with reloadData but it only updates the modified feild

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    if(new){
        NSInteger row = [listOfCars count];
        NSLog(@" row  %i", row);
        NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:row inSection:0]];
        //NSArray * foo = [NSArray arrayWithArray:<#(NSArray *)array#>
        [self.tableView beginUpdates];
        [self.tableView insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
        [self.tableView endUpdates];
        new = NO;
    }
    //This only works with "changed data" not new rows.
    [self.tableView reloadData];


}

This saves new rows to my database but the new row never appears. The InsertRows actually coreDumps on me. I am pretty sure I need to use the insertRowsAtIndexPaths but I have no clue where to put it so it will be executed once I have added the object to CoreData. Any ideas?

  • 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-20T01:08:45+00:00Added an answer on May 20, 2026 at 1:08 am

    You forget to insert the newly created car to the listOfCars array.

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

Sidebar

Related Questions

I have a table view, and if a certain row is tapped, the detail
I got a small issue. I have a detail view with a button. When
I have 2 views in my app 1st view: tableview and button(update) 2nd view:
I have a main table view and a detail view. when i click cell
In my app, I have a split screen in which the detail view is
In my tableview I have number of rows that have disclosure detail button accessory
I have a tableview and detail view app, in the tableview I have this
Here is my predicament: I have a tableview controller that loads a detail view
I have two tableview controllers showing CoreData objects. One is a detail view (with
I have Grouped Table View in which I want to display Contact details. But

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.