0
私は常に新しいデータで更新するデータベースを持っています。このデータを私のUITableView
のデータソースとして使用します。現在、NSNotifications
を使用して、UITableView
に新しいデータの挿入、削除、または更新を通知しています。しかし、私はdelegates
を1対1で使用する方がずっと良いと思っていました。iOS:この場合、代理人またはNSNotificationを使用する必要がありますか?
ここでは、何が起こっているかをよりよく示すためのコードです。より大きな範囲で
- (void)insertObject:(NSNotification *)notification {
NSNumber *object = [notification object];
[self.tableView beginUpdates];
[self.data insertObject:object atIndex:0];
[self.tableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withAnimation:NSTableViewAnimationEffectNone];
[self.tableView endUpdates];
}
https://stackoverflow.com/questions/21771606/objective-c-delegate-or-c-style-block-callbackを参照してください – rmaddy