Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lowcountry01

macrumors newbie
Original poster
Aug 13, 2009
7
0
So, in a pizza game app, there is one place where the user views the (pretend) restaurant's menu. What happens is the menu is stored in an sqlite file online, and when the user selects to look at the menu, the file is downloaded into the app's resources. The string "databasePath" is then set to the file path of the database file. A new array is made (myArray) to add the different pizzas from the menu to. Then, the app is set to get the different pizzas from the SQLite file and add them to the array. Later on, the names will be retrieved to add to a uiTableView. This is part of my code:
-----

sqlite3 *database;

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
NSLog(@"SQLite was okay 1st");
const char *sqlStatement = "select * from Menu";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
NSLog(@"SQLite was okay 2nd");
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *pizzaNames = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];


[myArray addObject:restaurantName];

[restaurantName release];
}
}
sqlite3_finalize(compiledStatement);

}
sqlite3_close(database);

-----

When I run the app and go to the part where this code is run, it says that there are no objects in the array. When I look at the NSLog, only "SQLite was okay 1st" is there, not "SQLite was okay 2nd." So, this rules out that it had trouble getting the right column or right row or whatever from the SQLite table. Seeing that the NSLog received the first entry seems to me that the possibility of the file being downloaded incorrectly is ruled out, because the database would not have returned "SQLITE_OK" if it had a problem downloading. However, I cannot figure out why the second one does not return "SQLITE_OK". The only thing I could think of is that the const. char. "sqlStatement" does not match the database, but it does. I have checked and rechecked again and again.

What else should I check? Is there notation or something else visibly wrong? I am at a complete standstill.
Thanks a ton!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.