small medium large xlarge

Back to: All Forums  Core Data
N50206170_1520_pragsmall
28 Oct 2009, 23:25
Gregory Rushton (3 posts)

Just got the book this week and I’m really enjoying it. In the examples, when a new entity is added using a button, the focus is put into the table and the first field in that table. How can I tell IB to drop the cursor into a field instead? For instance, when adding a new recipe, I’d prefer to have the cursor in the name field instead of the name column of the recipes table.

I can see in the attributes tab for the array controller a checkbox for “Select Inserted Objects”, but I don’t see any finer-grained control for this. Is subclassing the array controller and over-riding the add method the way to go here?

Thanks for any help!

-Greg Rushton

N50206170_1520_pragsmall
29 Oct 2009, 11:47
Gregory Rushton (3 posts)

I think what I really want is a custom add screen instead of trying to re-point the cursor. The NSPersistentDocument Core Data tutorial seems to cover this variation of adding an entity pretty well.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/08_CreationSheet/creationSheet.html#//apple_ref/doc/uid/TP40001799-CH284-SW2

Avatarsmall_pragsmall
29 Oct 2009, 17:17
Marcus S. Zarra (284 posts)

That is not something you can do in interface builder. To handle that you will need to bind the add button to a method somewhere (probably in the app delegate) and have the add method create the new NSManagedObject and also have it control where the focus moves to.

Needless to say that is not a function of Core Data. It is a function of the controller for the interface.

N50206170_1520_pragsmall
29 Oct 2009, 19:11
Gregory Rushton (3 posts)

Thanks Marcus, that makes perfect sense.

You must be logged in to comment