I am developing an navigation based app in which table data entered dynamically though another page. But when navigate back to table , it does not show the data. It shows the data only after existing application and relaunching it. Any help will be appreciated. Here is my code.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
listOfNotes=[[NSMutableArray alloc]init];
NSString *docsDir;
NSArray *dirPaths;
dirPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir=[dirPaths objectAtIndex:0];
databasePath=[[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent:@"myApplicationDatabase.sqlite"]];
const char *dbPath=[databasePath UTF8String];
if (sqlite3_open(dbPath, &contactDB)==SQLITE_OK) {
const char *sql="select notes from message";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(contactDB, sql, -1, &statement, NULL)==SQLITE_OK){
while (sqlite3_step(statement)==SQLITE_ROW) {
NSString *list=[NSString stringWithUTF8String:(char*)sqlite3_column_text(statement, 0)];
[listOfNotes addObject:list];
}
sqlite3_finalize(statement);
}
sqlite3_close(contactDB);
}
tableData=[[NSMutableArray alloc]init];
[tableData addObjectsFromArray:listOfNotes];
}
try to reload the table by