Wrong binding of ArrayController?

If I bind an ArrayController graphically in a macOS App, not document based, using CoreData, to persistentContainer.viewContext, I get following exception:


2017-09-18 12:53:17.525295+0200 Parlament[1349:76421] [General] An uncaught exception was raised

2017-09-18 12:53:17.525332+0200 Parlament[1349:76421] [General] [<NSApplication 0x6000001006c0> addObserver:<NSObjectParameterBinder 0x608000091c10> forKeyPath:@"persistentContainer.viewContext" options:0 context:0x6080000e3100] was sent to an object that is not KVC-compliant for the "persistentContainer" property.

Does anybody know the right binding or what to to do?

Replies

You have to bind the array controller to the Core Data managed object context. Bind the array controller's Managed Object Context binding to File's Owner and supply managedObjectContext as the model key path.


If that doesn't work, you are going to have to update your question with a lot more information on how you set up your array controller and bind it.

The persistentContainer.viewContext is the managed context -while there are no problems with Objective-C, the same code crashes in Swift. For example, create a simple application - Entity User with firstName, lastName String,a table view with two corresponding columns, bind an array controller to App Delegate' persistentContainer.viewcontext, fetching entity User, and you will get the error. Try it it with Objective-C, it has no problems.