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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:00:17+00:00 2026-05-22T17:00:17+00:00

i can successfuly delete data from tableview , but when i go to main

  • 0

i can successfuly delete data from tableview , but when i go to main menu and come back then i see all the old data,

how to make data consistent , i.e once deleted it will be gone forever

- (void)viewDidLoad
{
    [super viewDidLoad];
    appDelegate = (DatabaseTestAppDelegate *)[[UIApplication sharedApplication] delegate];

        {
     appDelegate.favDetail = [[NSMutableArray alloc] initWithObjects:@"1", @"2",@"4",nil];
        }

}


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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    appDelegate = (DatabaseTestAppDelegate *)[[UIApplication sharedApplication] delegate];



     NSString *cc=[appDelegate.favDetail objectAtIndex:indexPath.row];
    NSLog(@" vale is %d",indexPath.row);
    // Configure the cell...
     NSArray *theParameters = [cc componentsSeparatedByString:@","];



    NSLog(@"array is %@",cc);
          NSLog(@"arraytheParameters is %@",theParameters);

    cell.text=cc;//theParameters;
    return cell;
}



// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{   NSLog(@"matrix is her%@",appDelegate.favDetail);
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source



        [appDelegate.favDetail removeObjectAtIndex: indexPath.row];
        [tableView beginUpdates];
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject: indexPath] withRowAnimation:UITableViewRowAnimationFade];
        [tableView endUpdates];
    }   

     /*
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    } */


}



- (void)viewWillAppear:(BOOL)animated
{ [tableView reloadData];
    [super viewWillAppear:animated]; // no use , it shows old data
}

thanks

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

    If you are looking to save the state of your model beyond the life of your table view controller, there are few things you can do. One is to write the array to a file in the documents directory and read it back on reload. This would work well will small sets of data. But if you are going to use a large data set, you have to use Core Data.

    As for this specific case, you are reinitializing the data on every viewDidLoad. I suggest you do this in viewDidLoad –

    ...
    if ( appDelegate.favDetail == nil ) {
        appDelegate.favDetail = [[NSMutableArray alloc] initWithObjects:@"1", @"2",@"4",nil];
    }
    ...
    

    This will make sure that you don’t reinitialize it.

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

Sidebar

Related Questions

I can't seem to delete old records from my app on heroku. Currently the
I can successfully connect to MySQL from a DOS prompt, but when I try
I can successfully include main jquery files in /Scripts, but if my custom test.js
When using contentResolver.delete(uri, null, null) then determining success can be done by looking at
I'm creating a simple back-end app through which the user can create/update/delete database rows
I have an HBITMAP containing alpha channel data. I can successfully render this using
I'm using django non-rel ( http://www.allbuttonspressed.com/projects/django-nonrel ) and am trying to delete all the
What i want to do: delete an image file from the private internal storage
I have an NSOperation which fetches some objects from a core data persistent store
I have an application where I show data from a database. In fact we

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.