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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:11:01+00:00 2026-05-26T17:11:01+00:00

I am making a small app. And having a trouble right now. Trouble by

  • 0

I am making a small app. And having a trouble right now. Trouble by deleting a table customized cell.

it keep removing the top cell instead of the right selected cell. I delete cell number 20, it still delete the cell number 1. I don’t know why. please help me out. Really appreciate.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{
    [sortedArray removeObjectAtIndex:indexPath.row];
    [self.tableView reloadData];
}

and here is the array:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (detail == nil) {
        detail = [[UrlDetail alloc] init];
    }

    NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];

    self.arrayData = [NSMutableArray arrayWithContentsOfFile:path]; 

    NSMutableArray *filterArr = [self filterArray];

    sortedArray = [[NSMutableArray alloc] initWithArray:filterArr copyItems:YES];

    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
                                               initWithBarButtonSystemItem:UIBarButtonSystemItemAdd                                                                                                     
                                               target:self
                                               action:@selector(actionAddNewURL:)] autorelease];

}

and here is the filter function:

-(NSMutableArray *)filterArray
{

NSMutableArray *filterArr = [[NSMutableArray alloc] init];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];


[filterArr addObject:tempArray];
[tempArray release];

for (NSDictionary *item in arrayData) {
    if ([tempArray count]==0)
    {
        [tempArray addObject:item];
    }
    else
    {
        NSDictionary *anItem = [tempArray objectAtIndex:0];
        NSString *first = [[anItem objectForKey:@"url"] substringToIndex:1];
        NSString *last = [[item objectForKey:@"url"] substringToIndex:1];

        if ( [first isEqualToString:last]) 
        {
            [tempArray addObject:item];
        } else
        {
            tempArray = [[NSMutableArray alloc] init];
            [tempArray addObject:item];
            [filterArr addObject:tempArray];
            [tempArray release];
        }
    }
}
//    NSMutableArray *newArray = [[NSMutableArray alloc] initWithArray:filterArr copyItems:YES];
return filterArr;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if([sortedArray count]>0){

        NSLog(@"number of section: %d", [sortedArray count]);
        return [sortedArray count];
    }
    return 0;
}


- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section
{
    if (isTab) {
        if ([self.sortedArray count] > section) {
            NSDictionary *dictionary = [[sortedArray objectAtIndex:section] objectAtIndex:0];
            NSString *string = [dictionary objectForKey:@"url"];            
            return [NSString stringWithFormat:@"%@", [[string substringToIndex:1] uppercaseString]];
        }
        else return nil;
    } else
    {
        return nil;
    }
}

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    CustomCell *cell = (CustomCell *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
        cell = myOwnCell;
    }

    NSDictionary *dataItem = [[sortedArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];

    cell.urlName.text = [dataItem objectForKey:@"url"];
    cell.titleLabel.text = [dataItem objectForKey:@"title"];
    cell.urlName.font = [UIFont italicSystemFontOfSize:14.0];
    cell.imageIcon.image = [UIImage imageNamed:[dataItem objectForKey:@"image"]];

    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    // Configure the cell.
    return cell;
}
  • 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-26T17:11:02+00:00Added an answer on May 26, 2026 at 5:11 pm

    Try this one if it works:

    - (void) tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            NSString *key = [[sortedArray allKeys] objectAtIndex:indexPath.row];
    
            [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
            [sortedArray removeObjectForKey:key];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been making small scale projects for a while now. I haven't started a
In it's simplest explanation, I'm making a really small interactive movie app on Android.
I am having a small issue with MBProgressHUD in my app. Basically I am
I am making a small form for a php app and had a question
I'm making a small peer-to-peer app that holds a common collection of objects. This
I'm making a small app in Adobe Air which I need to interact with
I´m using Mac OS Lion, with java version 1.6.0_26 I'm making a small app
I have created a small app having navigation UI similar to jQuery Mobile site.
I'm new to node, express and jade and I'm making a small app that
I am making a small web app that allows users to submit html, css

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.