简体   繁体   English

从数据库中删除数据

[英]Delete the data from database

I am new in iPhone programming and I dont know much about database. 我是iPhone编程的新手,我对数据库了解不多。 I am making an iphone application in which I have used database for storing the contacts, whenever I add new contact It get add to the table view where others contacts are displaying. 我正在制作一个iphone应用程序,每当我添加新联系人时,我都在其中使用数据库来存储联系人。它将添加到显示其他联系人的表视图中。 But I want that If I dont need any contact then by clicking on the row of the table view it must delete from tableview as well as from database. 但是我想要,如果我不需要任何联系,那么通过单击表视图的行,它必须从表视图以及数据库中删除。 How Can I do it. 我该怎么做。 Please help me. 请帮我。

Thanks alot. 非常感谢。

you can use this code 您可以使用此代码

- (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];
    }   

        }

Here's a good tutorial of sqlite: http://www.icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/ 这是一个很好的sqlite教程: http : //www.icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/

you'll use sqlite3_prepare_v2 but I know there are some helper frameworks out there that people will recommend (I haven't used them so can't comment) 您将使用sqlite3_prepare_v2但我知道那里会有一些人们会推荐的帮助程序框架(我没有使用过,所以不能发表评论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM