Kuba Suder's blog on Mac & iOS development

Generating scaffold interfaces in Cocoa

Categories: Cocoa, Mac Comments: 0 comments

I discovered an interesting feature in Interface Builder a few days ago. It seems that it can generate a scaffolding UI for you based on a CoreData model. It works like this: first you have to design a data model in XCode model editor (which you have to do anyway if you want to use Core Data; if you don’t, it won’t make sense to draw the model only to get the scaffold UI, it will be faster to make it yourself…). Let’s say you have a model like in this picture:

XCode data model editor

To generate the UI, you just grab an entity from the diagram and drag&drop it into a blank window in IB :) The trick is that you need to hold Alt while doing this, otherwise you’ll just drag the entity around the diagram. Then you need to choose one of 3 form versions and select the fields that you want in the form. And you get something like this:

Single contact form dialog

Or like this (this shows objects in a grid):

Contact list window

Or this:

Contact list with an integrated contact edit form

Of course, most of the time you’ll need to make some corrections before you can use it, and it isn’t hard to make something like this yourself, but this can save you a few minutes. And it’s cool anyway :) What’s funny is that I’ve just finished Aaron Hillegass’s book and I’ve read all the available chapters from the Rubycocoa book, and none of them mentioned this feature even once… I learned about this from a Wikipedia entry for Core Data.

Leave a comment


This will only be used to display your Gravatar image.


What property can you use on iOS to get a unique device ID that the user can reset in Settings?