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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:59:08+00:00 2026-06-14T09:59:08+00:00

I want to insert and delete data by adding a button, when i click

  • 0

I want to insert and delete data by adding a button, when i click my button query works but data is not inserted or deleted at once i have to restart the app to see the inserted or deleted row in my tableView, i also added tableView reload data but it do not work here is some peace of code
in this view i want to insert or delete row

- (void)viewDidLoad
{
    [super viewDidLoad];
    isLoadingAlphabets=1;

    DBHandler *obj= [[DBHandler alloc]init];
    Array = [obj loadFavoriteWords];

    isSearching = 0;
    displayItems = [[NSMutableArray alloc] initWithArray:Array];    
    // Do any additional setup after loading the view, typically from a nib.
      [tableview reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
    - (void)dealloc {
        [tableview release];
        [super dealloc];
    }
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(isSearching){
        return [displayItems count];   
    }
    else {
        NSLog(@"Count: %d", [Array count]);
        return [Array count];
    }
}

here is my button from where i m adding or deleting row in favorites

- (void)viewDidLoad
{
     [super viewDidLoad];

    DBHandler* db=[[DBHandler alloc]init];
   // NSLog(@"asas%@",detail_word);
    if(![db isAlreadyInFavorites:word_id])
         {
            [btnFavorite setImage:[UIImage imageNamed: @"star-grey.png"  ] forState:UIControlStateNormal];
        } else {
            [btnFavorite setImage:[UIImage imageNamed:@"star-yellow.png"] forState:UIControlStateNormal ];  
        }
    // Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btn:(id)sender {
    DBHandler *db = [[DBHandler alloc]init];

    if(![db isAlreadyInFavorites:word_id]){

        [btnFavorite setImage:[UIImage imageNamed:@"star-yellow.png"] forState:UIControlStateNormal];
        [db addFavoriteWord:word_id];

    }
    else{

        [db deleteFavoriteWord:word_id];

        [btnFavorite setImage:[UIImage imageNamed:@"star-grey.png"] forState:UIControlStateNormal];

    } 
}
  • 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-14T09:59:09+00:00Added an answer on June 14, 2026 at 9:59 am

    just remove all data from your displayItems or from Array and add again this new data from database like belllow

    - (IBAction)btn:(id)sender {
        DBHandler *db = [[DBHandler alloc]init];
    
        if(![db isAlreadyInFavorites:word_id]){
    
            [btnFavorite setImage:[UIImage imageNamed:@"star-yellow.png"] forState:UIControlStateNormal];
            [db addFavoriteWord:word_id];
    
        }
        else{
    
            [db deleteFavoriteWord:word_id];
    
            [btnFavorite setImage:[UIImage imageNamed:@"star-grey.png"] forState:UIControlStateNormal];
    
        } 
        Array = [db loadFavoriteWords];
        if([displayItems count]>0){
              [displayItems removeAllObjects];
        }
        displayItems = [[NSMutableArray alloc] initWithArray:Array];    
        [tableview reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have an 'updateinfo' table in order to record every update/insert/delete operations
I have a asp.net 4.0 web application that uses linqtosql to insert/update/delete data from
I want to create a RESTful API for a website which will collect/insert/delete data
I am new to core data .I have already performed insert and delete operations
For example, I want to search/insert/get/delete data from database and I'm working with wcf
I want to insert some session data in a database. I have one table
I have a xml file which contains data I want to insert into a
I Have two Queue and i Want To Delete Data is Duplicate and i
I want to insert and delete some chars in the middle of a file.
i want to build a tree in java. operations such as insert delete update.

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.