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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:35:28+00:00 2026-06-18T17:35:28+00:00

Im reordering my TableViewCells with the following code: – (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath{ [self.ammoTable

  • 0

Im reordering my TableViewCells with the following code:

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath{
[self.ammoTable moveRowAtIndexPath:indexPath toIndexPath:[NSIndexPath indexPathForRow:[self.tableArray count] - 1 inSection:1]];
}

-(IBAction)setEdit{
if ([self.button.currentTitle isEqualToString:@"Edit"]) {
    self.ammoTable.editing = YES;
    [self.button setTitle:@"Done" forState:UIControlStateNormal];
}
else{
    self.ammoTable.editing = NO;
    [self.button setTitle:@"Edit" forState:UIControlStateNormal];

}
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath   
*)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
    // fetch the object at the row being moved
NSString *r = [self.tableArray objectAtIndex:fromIndexPath.row];

    // remove the original from the data structure
[self.tableArray removeObjectAtIndex:fromIndexPath.row];

    // insert the object at the target row
[self.tableArray insertObject:r atIndex:toIndexPath.row];

[self.ammoTable reloadData];
}

Everything works great, except when you leave the view and return to it. If i move the cells around, when the view comes back up, they are all in the original order that they were in. Is there any reason for this? Thanks for the help!

  • 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-18T17:35:29+00:00Added an answer on June 18, 2026 at 5:35 pm

    because you are reloading your tableview with old array i.e. not with updated array
    that means you are reinitializing your array ,it may be in viewDidLoad.
    create & initialize your array in appDelegate .Use this array & make changes when you moves cell,it will persist order of elements.

    see this link to how to create & access array from appDelegate

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

Sidebar

Related Questions

Are reordering and interleaving interchangeable terms when it comes to code compilation, optimization and
As the title really - I have some code for reordering some thumbnails in
. Hello, I have the following code to set the re-ordering of the tableView.
I am looking for things like reordering of code that could even break the
How would I go about reordering divs without altering the HTML source code? example,
I have written a chunk of code that is aimed at reordering pages. <form
from the docs: the reordering control temporarily replaces any accessory view. So when I
My question is like this: Reordering UITableView without reorder control , I use these
I am looking to allow reordering of UITableViewCell s and deleting via swipe to
In order to have list reordering functionality I turned to this implementation . My

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.