问题
I am using a UISplitViewController to manage the Master and Detail view. Everything is working fine going from master to detail. I can select an item from the list and through the delegate it updates the detail view.
I want to be able to delete an item using a button on the detail view. This is very simple to do on the detail view. However, I cannot seem to figure out how to change the master view to reflect the fact that an item has been deleted.
Here is my example: SampleCode
回答1:
Make the master a delegate of the detail view. That is: when you fire up the detail from the master, tell the detail who the master is, preferably by using a delegate construction.That way the detail can inform the master when any changes should occur.
Or you can also put the data in CoreData, and have the master notified automatically when a changes occurs in the CoreData tables. Check NSManagedObjectContextObjectsDidChangeNotification
for more info.
来源:https://stackoverflow.com/questions/10463394/objectivec-protocol-issue-detail-master-communication