簡體   English   中英

從數據庫中刪除數據

[英]Delete the data from database

我是iPhone編程的新手,我對數據庫了解不多。 我正在制作一個iphone應用程序,每當我添加新聯系人時,我都在其中使用數據庫來存儲聯系人。它將添加到顯示其他聯系人的表視圖中。 但是我想要,如果我不需要任何聯系,那么通過單擊表視圖的行,它必須從表視圖以及數據庫中刪除。 我該怎么做。 請幫我。

非常感謝。

您可以使用此代碼

- (void)viewDidLoad {

self.navigationItem.rightBarButtonItem = self.editButtonItem;

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

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   

        }

這是一個很好的sqlite教程: http : //www.icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/

您將使用sqlite3_prepare_v2但我知道那里會有一些人們會推薦的幫助程序框架(我沒有使用過,所以不能發表評論)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM