I try to learn Core Data and am stumbling across a problem: I set up a simple data model and I used bindings to show some properties of my entity instances in a table view. The table view is embedded (left side) in a split view. If something is selected in the table view, the right side should show something like a "detailed item view" in which I can see (and change) all the properties of my entity. If nothing is selected, the view on the right should show a different view (which just contains a lable saying that nothing is selected). The app (which is written in Swift 3 using Xcode 8) looks like this at the moment:
So adding and removing works just fine. But I do not know how I can change the view to be shown on the right depending on wether something is selected or not. First, I tried to lay out the UI using storyboard which looks like the following:
The two views on the right are the views to be placed in the bottom middle view. I gave them a Storyboard ID so that I can use them to instantiate a new ViewController. I also set the ListViewController to be the delegate of the contained tableView so that I can use tableViewSelectionDidChange(_ notification: Notification) to track the selection. Now, I do not know how to properly override that function so that, when no item in the table view is selected, the NoSelectionViewController is shown on the right side of the NSSplitView. Of course, I do not know either how to show the StudentViewController once something is selected. And how would I pass the data to that StudentViewController (e.g. how can I know which student was selected and access the properties)?