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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:55:35+00:00 2026-06-17T15:55:35+00:00

I am working with a UITableView and for each of the objects in the

  • 0

I am working with a UITableView and for each of the objects in the array that is the datasource for the UITableView, I am deleting them if they meet a certain if statement. My problem is that it only deletes every-other object from the array.

Code:

UIImage *isCkDone = [UIImage imageNamed:@"UITableViewCellCheckmarkDone"];
int c = (tasks.count);
for (int i=0;i<c;++i) {
    NSIndexPath *tmpPath = [NSIndexPath indexPathForItem:i inSection:0];
    UITableViewCell * cell = [taskManager cellForRowAtIndexPath:tmpPath];
    if (cell.imageView.image == isCkDone) {
        [tasks removeObjectAtIndex:i];
        [taskManager deleteRowsAtIndexPaths:@[tmpPath]
                withRowAnimation:UITableViewRowAnimationLeft];
    }
}

What is wrong with this?

  • 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-17T15:55:36+00:00Added an answer on June 17, 2026 at 3:55 pm

    You must run your loop backwards, i.e.

    for (int i=c-1;i>=0;--i)
    

    If you are running it the other way round, removing an object at index position i moves the objects in the array that are behind i one position forward. In the end you will even run over the bounds of your array.

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

Sidebar

Related Questions

I have an application that I'm working on that has a UITableView. Each cell
So I have a nicely working UITableView consisting of 3 rows (each including and
Currently I'm working on an application that will have a UITableView for a news
I have a UITableView where each cell is an image. Only one cell is
hi i am working on UITableView custom cell for twitter, for each cell i
I am working on an app that has a TabView controller, and in each
I have a UITableView in which each UITableViewCell having a UIView on them and
I'm working on proof of concept project. That is using a UITableView to display
I have two instances of UITableView in one app, and the problem is that
I have a working UITableView filled with some options for my app, and i

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.