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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:39:38+00:00 2026-06-13T03:39:38+00:00

I’ve a problem deleting a row from a table view. Here is the code

  • 0

I’ve a problem deleting a row from a table view. Here is the code that is called when the button on the row is pressed. I’ve used the tag parameter to tell me which row I’m dealing with, which is why I call reloadTableView at the end to reapply all the tags. If I update the visible rows I was having crashes. So I must be doing something wrong here?

- (void) deleteLineItem:(id)sender
{
    UIButton *deleteBtn = sender; // Need to get tag (which was set to table row)
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(deleteBtn.tag/3) inSection:0];
    NSLog(@"Removed entry at %d, with tag %d", indexPath.row, deleteBtn.tag);
    [self.productItems removeObjectAtIndex:indexPath.row];

    [self.tableview beginUpdates];
    [self.tableview deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
    [self.tableview endUpdates];

    // Hack to keep table animation ok as we have to do it after the row delete above
    [self performSelector:@selector(reloadTableview) withObject:nil afterDelay:0.35];
}

In this case I have two rows in the table.
The datasource is as follows:

Printing description of self->productItems:
(__NSArrayM *) productItems = 0x084fa3b0 @"2 objects"

The indexPath is as follows:

Printing description of indexPath:
<NSIndexPath 0x1069bff0> 2 indexes [0, 1]

When the endUpdates metod is called I get the following crash in the console

2012-10-17 17:04:33.424 myAppname[5782:15203] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x1bf0022 0x1918cd6 0x1bdcd88 0xa5553 0xa576b 0x925420 0x963284 0x9633d0 0x925219 0x8fd4f2 0x8fa4c3 0x9050b7 0x9050e5 0xa6ae1 0x1bf1e99 0x87814e 0x8780e6 0x91eade 0x91efa7 0x91e266 0xb39a1a 0x1bc499e 0x1b5b640 0x1b274c6 0x1b26d84 0x1b26c9b 0x25007d8 0x250088a 0x875626 0x1f2ba 0x2ba5)
terminate called throwing an exception(lldb)

I have no idea why is causing a problem.

  • 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-13T03:39:39+00:00Added an answer on June 13, 2026 at 3:39 am

    The code does not look very robust. Seems like you have set the deleteBtn.tag to a bad value (between 3 and 5, to be more precise) where you had only one cell. Just a guess.

    A more robust technique for such tasks, which I use, is to implement the IBAction in my UITableViewCell subclass and then propagate the request to the controller via delegation and the cell itself as an argument. In the controller then I retrieve the indexPath via

    [self.tableView indexPathForCell:cell];
    

    This way I avoid such hacks.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
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
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.