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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:21:01+00:00 2026-06-08T08:21:01+00:00

NSMutableArray *objects holds some objects which I use to display the content of my

  • 0

NSMutableArray *objects holds some objects which I use to display the content of my table view cells. If objects.count is 0 I would like to enable the editing mode of my table view when viewDidLoad:

- (void)viewDidLoad {

    // If there is no content to present enable editing mode
    if (self.objects.count == 0) [self setEditing:YES animated:YES];
}

This toggles the self.editButtonItem and inserts a new row (stating “Tap here to add a new element”) into my table view:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {

    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];

    if (self.editing) {
        [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.objects count] inSection:0]] 
                              withRowAnimation:UITableViewRowAnimationAutomatic];
    }

    else {
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.objects count] inSection:0]] 
                              withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

Unfortunately this setup results in a crash:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1914.85/UITableView.m:833

Is it not possible to toggle the editing mode programmatically? If the user touches the self.editButtonItem everything works fine – and as far as I know, this editButton does the same I’m doing in viewDidLoad.

What am I doing wrong?

  • 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-06-08T08:21:04+00:00Added an answer on June 8, 2026 at 8:21 am

    i think there are 2 different questions here.

    one, it is possible to perform setEditing:animated: programmatically.

    but i don’t think that’s what you really want to try to do here. the editing mode is for the user to manually edit the table, and present the little red button on the left, and possibly the little movement indicator on the right if you have those settings set.

    the better thing to do is when you find your objects has changed, perform a [self.tableView reloadData];, and just make sure that your UITableViewDataSource protocol methods implemented do the right thing. this will include the implementation of tableView:numberOfRowsInSection: (and possibly also numberOfSections) and also tableView:cellForRowAtIndexPath: . this will cause the items to appear in the tableView as objects changes.

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

Sidebar

Related Questions

I have an NSMutableArray which can hold several objects. I would like to check
I would like to use an array of pointers to instances of objects, but
I have an NSMutableArray which has five objects in it. I want to insert
I have an NSMutableArray with objects within it and I use the following code
I've got NSMutableArray with objects Link which has parameter Byte taskOne . I have
I have an NSMutableArray of objects (in my case some systems). I'm requesting new
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I have an NSMutableArray with many objects in it. Some are NSStrings, others are
I have an NSMutableArray of NSString objects. How would I make an NSString that
I'd like to return an NSMutableArray with three objects. Here's what I've got: NSMutableArray

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.