2011-11-12 50 views
1

我正在开发一个基于导航的应用程序,其中表数据通过另一个页面动态输入。但是,当回到表格时,它不显示数据。它仅在现有应用程序并重新启动后显示数据。任何帮助将不胜感激。这是我的代码。表数据不会动态加载

- (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]; 

    } 

回答

2

尝试通过

[table reloadData]; 
+0

我已经试过[资料表reloadData],但应用程序崩溃重装表。 – NoviceDeveloper

+0

你的崩溃记录是什么? – Maulik

+0

nsmutablearray可能不会响应[table reloadData]中的[tabledata reloadData] – NoviceDeveloper