Guest User

Untitled

a guest
Aug 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Table data does not reload dynamically
  2. - (void)viewWillAppear:(BOOL)animated {
  3. [super viewWillAppear:animated];
  4. listOfNotes=[[NSMutableArray alloc]init];
  5.  
  6. NSString *docsDir;
  7. NSArray *dirPaths;
  8. dirPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  9. docsDir=[dirPaths objectAtIndex:0];
  10.  
  11. databasePath=[[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent:@"myApplicationDatabase.sqlite"]];
  12. const char *dbPath=[databasePath UTF8String];
  13. if (sqlite3_open(dbPath, &contactDB)==SQLITE_OK) {
  14. const char *sql="select notes from message";
  15. sqlite3_stmt *statement;
  16. if (sqlite3_prepare_v2(contactDB, sql, -1, &statement, NULL)==SQLITE_OK){
  17.  
  18. while (sqlite3_step(statement)==SQLITE_ROW) {
  19. NSString *list=[NSString stringWithUTF8String:(char*)sqlite3_column_text(statement, 0)];
  20. [listOfNotes addObject:list];
  21. }
  22. sqlite3_finalize(statement);
  23.  
  24. }
  25. sqlite3_close(contactDB);
  26. }
  27. tableData=[[NSMutableArray alloc]init];
  28. [tableData addObjectsFromArray:listOfNotes];
  29.  
  30. }
  31.  
  32. [table reloadData];
Add Comment
Please, Sign In to add comment