从ios更新SQLite单元

我正在阅读来自sqlite文件的信息,我能够从数据库中读取数据,并用数据库中的对象创build一个数组。 当我的代码发生什么事的时候,我需要更新数据库的条目。 例如,一个问题有一个名为“完成”的列设置为否,当被回答时,我想将该值更改为是。 我如何打开一个数据库,并在Xcode上编辑单元格?

首先没有人从头开始回答你。 首先,你需要做一些事情,并问这里,如果你卡住的地方。无论如何,这里有一些教程,你可以创build,更新,读取和删除sqlite表:

http://www.raywenderlich.com/913/sqlite-tutorial-for-ios-making-our-app

http://www.tutorialspoint.com/ios/ios_sqlite_database.htm

NSString *status; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *dbPath=[[NSString alloc]initWithString:[documentsDir stringByAppendingPathComponent:@"YOUR DATABASE NAME.sqlite"]]; NSLog(@"Database Path %@",dbPath); sqlite3_stmt *statement; if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) { NSLog(@"open"); NSString *updateSQL = [NSString stringWithFormat: @"UPDATE Table_Name set complete = 'YES' where id = 1994"]; const char *update_stmt = [updateSQL UTF8String]; sqlite3_prepare_v2(database, update_stmt, -1, &statement, NULL); if (sqlite3_step(statement) == SQLITE_DONE) { status=@" Updated"; } else { status=@"Error occured"; }