0
我有UITableViewController
視圖,它使用SQLLite DB作爲數據源來構建其行,如下所示。當底層SQLite數據庫發生更改時更新UITableView
我也有UIViewController
它更新了SQL Lite數據庫,其中UITableViewController
使用。但是,它不會更新UITableView
,因爲我們假設它在查詢SQLLite時會知道這些更改。
的問題,我注意到了應用「有時」崩潰時,我從UIViewController
快速切換 - 以UITableViewController
- 在SQL精簡版數據庫添加條目之後。
我是新來的目標C和iOS,但我知道在Java/Android。在這種情況下,我需要通知視圖底層數據源發生變化(使用通知)。否則可能會發生崩潰/錯誤。
我需要在iOS中做同樣的事嗎?我該怎麼做?
- (int)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
MyAPPAppDelegate *appDelegate = (MyAPPAppDelegate *)[[UIApplication sharedApplication] delegate];
return [appDelegate.dataModel countMessages] ;
}