使用Objective C Wrapper for sqlite更新查询

时间:2010-04-23 10:49:30

标签: objective-c iphone sqlite wrapper

嘿我正在使用http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ 包装。

我的代码是:

    - (IBAction)UpdateButtonPressed:(id)sender 
    {


        Sqlite *sqlite = [[Sqlite alloc] init];
        NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@"Money"ofType:@"sqlite"];
        if (![sqlite open:writableDBPath])
            return;


        NSArray *query = [sqlite executeQuery:@"UPDATE UserAccess SET Answer ='Positano';"];
            NSDictionary *dict = [query objectAtIndex:2];
            NSString *itemValue = [dict objectForKey:@"Answer"];
            NSLog(@"%@",itemValue);
}

答案是列名,UserAccess是表名。 该列位于表格的第3位

我做错了为什么会崩溃???

2 个答案:

答案 0 :(得分:1)

@"UPDATE UserAccess SET Answer ='Positano';"]; 
NSArray *query2 = [sqlite executeQuery:@"SELECT Answer FROM UserAccess;"]; 
NSDictionary *dict = [query2 objectAtIndex:0]; 
NSString *itemValue = [dict objectForKey:@"Answer"]; 

答案 1 :(得分:0)

更新查询不会返回任何结果。在执行SELECT查询后,您通常会使用objectAtIndex,但它不适用于UPDATE。