sqlite3_stmt *stmt;
NSString *selectQuery =[NSString stringWithFormat:@"select * from myaccount"];
NSMutableArray *fl =[[NSMutableArray alloc]init];
NSString *sname;
NSString *myMobNo;
NSMutableString *str = [[NSMutableString alloc]init];
if (sqlite3_prepare_v2(db, [selectQuery UTF8String], -1, &stmt, nil) == SQLITE_OK) {
while (sqlite3_step(stmt) == SQLITE_ROW) {
sname = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 1)];
myMobNo = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 4)];
[str appendString:[NSString stringWithFormat:@"%@!%@",sname,myMobNo]];
[fl addObject:str];
}
}
sqlite3_finalize(stmt);
return fl;
我在我的项目中使用带有 SQL Lite 的 Objective C。当我调用上述方法时,我在 If 条件下收到 EXC_BAD_ACCESS 错误。我的代码有什么问题。任何帮助将不胜感激。提前致谢。
0x0003c099 -[DBModel getCName] + 112
1 Kinkey 0x0001d623 -[ChatViewController viewDidLoad] + 302
2 0x34dae579 <redacted> + 364
3 0x34e031f7 <redacted> + 26
4 0x34e0313d <redacted> + 28
5 0x34e03021 <redacted> + 32
6 0x34e02f4d <redacted> + 272
7 0x34e02699 <redacted> + 64
8 0x34e02581 <redacted> + 324
9 0x34df0b5b <redacted> + 858
10 0x34df07fb <redacted> + 38
11 0x0004cd33 -[ChatView tableView:didSelectRowAtIndexPath:] + 970
12 0x34e5131d <redacted> + 876
13 0x34ed3da9 <redacted> + 156
14 0x3388f657 <redacted> + 450
15 0x32f55857 <redacted> + 14
16 0x32f55503 <redacted> + 274
17 0x32f54177 <redacted> + 1230
18 0x32ec723d CFRunLoopRunSpecific + 356
19 0x32ec70c9 CFRunLoopRunInMode + 104
20 0x36aa533b GSEventRunModal + 74
21 0x34de32b9 UIApplicationMain + 1120
22 0x00002a31 main + 108
23 0x000024cc start + 40
NSMutableArray *Details = [[DBModel database]getCName];
NSArray *array = [[Details objectAtIndex:0] componentsSeparatedByString:@"!"];
acName = [array objectAtIndex:0];
acMobileNo = [array objectAtIndex:1];
if ((char *)sqlite3_column_text(stmt4, 1)!= nil) {
sname = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt4, 1)];
}