I am having issues with the following code which loads an SQLite database.
- (NSArray *)getDatabase {
NSLog(@"Get Database Called");
NSMutableArray *retval = [[[NSMutableArray alloc] init] autorelease];
NSString *query = @"SELECT Description, UniqueID, HexCoords, NoHexCoords, NoAnnots, AnnotText, DescriptionFormatting, HexCoordsPortrait FROM MainTable";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(_database, [query UTF8String], -1, &statement, nil)
== SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *nameChars = (char *) sqlite3_column_text(statement, 0);
char *desChars = (char *) sqlite3_column_text(statement, 1);
int uniqueID = sqlite3_column_int(statement, 2);
From using breakpoints I can see that the problem is with the if statement and that the code never gets past this if statement. Can anyone spot what might be wrong ? The code was working a few months ago and I have recently upgraded to xCode 4.3 so might this be the problem ?
Thank in advance.
Yeah i agree With Joachim. there is a problem sometimes the DB doesnot really connect. what i do is a couple of things. First i add following Code in my Application App Delegate.
Call This Function in ApplicationDidFinishLaunching.
Now remove the data base that is in ur bundle currently. (MAKE SURE U HAD BACKUP OF IT). And (if Possible Delete All the project From Iphone Simulator Folder) Coz sometimes the previous Database is attached.
Clean Your project, Add the Data Base in ur bundle. Compile it..
Let Me know if it worked
the Get Path Function