I am using sqlite database for iphone app. but its crash on "while loop" line while retrieving data from database sometimes.
-(void)GetMethod
{
NSString *query = [[NSString alloc] initWithFormat:@"SELECT * FROM errorlogs"];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [query UTF8String],-1, &statement, nil) == SQLITE_OK)
{
while (sqlite3_step(statement) == SQLITE_ROW) **// EXC_BAD_ACCESS ON THIS LINE**
{
char *uid1 = (char *)sqlite3_column_text(statement, 0);
NSString *uid = [NSString stringWithFormat:@"%s",uid1];
}
}
sqlite3_finalize(statement);
}
why I am getting this EXC_BAD_ACCESS on while loop.
Thanks.
Try using the FMDB framework, it helped me a lot in my project.
Here's the link: https://github.com/ccgus/fmdb
Give it a look if you can ;)
Either sqlite3_step(statement)
or SQLITE_ROW
is not initialized, or has already been released. When it runs the equality check on the nonexistent object, it throws EXE_BAD_ACCESS.
Are you returning any rows?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With