別のクラスから tableView をリロードしようとしています。コンソールにいくつかの NSLog を表示した後、データが変更されていますが、変更されていません。以下はいくつかのコードです:
SecondViewController.m
RootViewController *test = [[RootViewController alloc] init];
// Set up database connection
NSString *myDB = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"flashpics.db"];
database = [[Sqlite alloc] init];
[database open:myDB];
[database executeNonQuery:@"INSERT INTO albums (id, name, connections) VALUES (?,?,'No Connections')", theID, theName];
[test.listOfItems addObject:theName];
RootViewController *controller = [[RootViewController alloc] init];
[controller.tableView reloadData];
[self dismissModalViewControllerAnimated:YES];
おそらく存在する最も簡単な質問の1つを解決するのを手伝ってくれませんか?
ありがとう、コールトン
EDIT#1: NSLogs には次のように表示されます。これは何かできるでしょうか?
__NSAutoreleaseNoPool(): Object 0x5883000 of class UITableView autoreleased with no pool in place - just leaking
編集 #2: SecondViewController.m にさらにコードを追加
編集#3:何らかの理由で機能していません。
SecondViewController.m
RootViewController *controller = [[RootViewController alloc] init];
[RootViewController refreshTableView];
RootViewController.m
- (void) refreshTableView {
[self.tableView reloadData];
NSLog(@"Refreshing TableView - %@", listOfItems);
}
配列に「neato」を挿入しました。次に、SecondViewController.m の reloadTableView を RootViewController.m に呼び出しました。出力は得られましたが、tableView は更新されませんでした。以下はNSLogです。
Refreshing TableView - (
"Default Album",
"Hello.",
"This is cool!",
hi,
neato
)
PS結果は得られませんが、NSLogを介して言うようにプログラムしたものは得られます。