What do you associate with the NSArrayController Context managed object in Xcode 4?

I am trying to create a document-based beer review application that allows you to enter your notes. I built the model in Core Data and the view in Interface Builder. Following some Xcode 3-based tutorials, I was told to connect the new NSArrayController to the managedObjectContext of the file owner. If I try to do this in Xcode 4, a circular exclamation mark will appear around the inspector for NSArrayController next to “Model Key Path”.

I can load the .xib file in Interface Builder in Xcode 3, make this connection, and then build it in Xcode 4 and run, but each field causes a validation error.

The model has an object called Scoresheet, which has a property called date, which is NSDate. But if I bind it to an NSDatePicker value and try to save it to disk, it says that I have "multiple validation errors." How can it be ? They are both NSDates, aren't they? In fact, I have the same problem with binding to everything; none of my user interface objects will work with my model.

The only thing I can understand is that there is something wrong with the connection between the file owner and NSArrayController.

At the moment, I have not written any code because I understand that I do not just need to bind the user interface fields and the main data. Is it different because I use a document based application? (I cannot get it to work in a single window application.)

The answer "do not use master data" will not be productive; I know that I can just return to a regular data object. I would like to understand this in the context of master data, if possible.

TIA!

(Update: This question seems to displease many people. I consulted the Zarra book on basic data, the Hillegas Cocoa programming book, and two O'Reilly books. They all seem to be based on Xcode 3.)

+7
source share
2 answers

NSPersistentDocument has its own managed entity context, and you must bind the NSArrayController in the xib file of the document to this managed entity context.

For example, if your document class is called MyDocument, then Xcode will automatically create the file MyDocument.h / .m / .xib for you. In .xib, the file owner is an instance of your MyDocument class, and you can bind NSArrayController to it with the File Owner -> managedObjectContext binding.

+4
source

I ran into the same problem (CarLot example in Chapter 11 Hilgass, right?)

The following blog entry belongs to a developer who wrote and maintains an extension for use with NSManagedObjects and considers this a bug in Xcode 4 and sent a report to rdar: http://danieltull.co.uk/blog/2011/04/20/xcode -4-and-creating-nsmanagedobject-subclasses /

I have a machine with Xcode 3, I will eventually give up on this in 4, create a project in Xcode 3 and import it into Xcode 4.

Edited to add: adding an item to Xcode 3 and plugging in a socket and then importing the project into Xcode 4 works fine, it looks like this is a bug in Xcode 4. I don't get validation problems with Xcode 4 doing this.

0
source

All Articles