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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:59:47+00:00 2026-05-30T19:59:47+00:00

I’m working form the big nerd ranch book, iphone programming. I’m working through Chapt

  • 0

I’m working form the big nerd ranch book, iphone programming. I’m working through Chapt 11 where you implement your own setEditing method:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    if( editing) {

        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[teams count] inSection:0];

        NSArray *paths = [NSArray arrayWithObject:indexPath];

        [[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationLeft];

    }
    else {
        /*
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[teams count] inSection:0];

        NSArray *paths = [NSArray arrayWithObject:indexPath];

        [[self tableView] deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
         */
    }
}

When I run this the whole app does a Sigabort without any info other than that. The line that seems to cause the problem is this one:

[[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationLeft];

I’m not sure what I’m doing wrong. What else would be good to see?

This is the whole file:

//
//  TeamsViewController.m
//  TeamTrackerClient
//
//  Created by Mark Steudel on 3/4/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "TeamsViewController.h"
#import "Team.h"

@implementation TeamsViewController

-(id) init
{
    self = [super initWithStyle:UITableViewStyleGrouped];

    teams = [[NSMutableArray alloc] init];

    Team *team = [[Team alloc] init];
    team.teamName = [NSString stringWithFormat: @"Fighting Axons"];
    team.teamCode = [NSString stringWithFormat: @"FA1"];

    [teams addObject:team];


    Team *team2 = [[Team alloc] init];
    team2.teamName = [NSString stringWithFormat: @"Pipers Peddlers"];
    team2.teamCode = [NSString stringWithFormat: @"PP1"];

    [teams addObject:team2];

    return self;
}

- (id) initWithStyle:(UITableViewStyle)style
{
    return [self init];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
 // Implement loadView to create a view hierarchy programmatically, without using a nib.
 - (void)loadView
 {
 }
 */

/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad
 {
 [super viewDidLoad];
 }
 */

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (UIView *) headerView
{
    if( headerView)
        return headerView;

    UIButton *editButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [editButton setTitle: @"Edit" forState: UIControlStateNormal];

    float w = [[UIScreen mainScreen] bounds].size.width;

    CGRect editButtonFrame = CGRectMake(8.0, 8.0, w - 16.0, 30.0);
    [editButton setFrame:editButtonFrame];

    [editButton addTarget:self 
                   action:@selector(editingButtonPressed:) 
         forControlEvents:UIControlEventTouchUpInside];

    CGRect headerViewFrame = CGRectMake(0, 0, w, 48);
    headerView = [[UIView alloc] initWithFrame:headerViewFrame];

    [headerView addSubview:editButton];

    return headerView;
}


- (void) editingButtonPressed: (id) sender
{
    if( [self isEditing] ) {
        [sender setTitle:@"Edit" forState:UIControlStateNormal];

        [self setEditing:NO animated:YES];
    }
    else {
        [sender setTitle: @"Done" forState:UIControlStateNormal];

        [self setEditing:YES animated:YES];
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [self headerView];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return [[self headerView] frame].size.height;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
    Team *t = [teams objectAtIndex:[sourceIndexPath row]];

    [teams removeObjectAtIndex:[sourceIndexPath row]];

    [teams insertObject:t  atIndex:[destinationIndexPath row]];

}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if( editingStyle == UITableViewCellEditingStyleDelete ) {
        [teams removeObjectAtIndex:[indexPath row]];

        [tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationFade];
    }
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    if( editing) {

        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[teams count] inSection:0];

        NSArray *paths = [NSArray arrayWithObject:indexPath];

        [[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationLeft];

    }
    else {
        /*
         NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[teams count] inSection:0];

         NSArray *paths = [NSArray arrayWithObject:indexPath];

         [[self tableView] deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
         */
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int numberOfRows = [teams count];

    if( [self isEditing] )
        numberOfRows++;

    return numberOfRows;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];

    if( !cell ) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
    }

    if( [indexPath row] < [teams count] ) {
        Team *t = [teams objectAtIndex:[indexPath row]];
        [[cell textLabel] setText:[t teamName]];
    }
    else {
        [[cell textLabel] setText: @"Add New Item ... "];
    }

    Team *t = [teams objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[t teamName]];

    return cell;
}
@end
  • 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-30T19:59:49+00:00Added an answer on May 30, 2026 at 7:59 pm
        [[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationLeft];
    

    this make the table view reload data ..and check the data in its datasource methods..

    i believe it is crashing on

    Team *t = [teams objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[t teamName]];
    

    there might be no objects in the teams array on here for the new index paths…

    check by breakpointing here..

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to loop through a bunch of documents I have to put
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
I want to count how many characters a certain string has in PHP, 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.