Dan Wood: The Eponymous Weblog (Archives)

Dan Wood Dan Wood is co-owner of Karelia Software, creating programs for the Macintosh computer. He is the father of two kids, lives in the Bay Area of California USA, and prefers bicycles to cars. This site is his older weblog, which mostly covers geeky topics like Macs and Mac Programming. Go visit the current blog here.

Useful Tidbits and Egotistical Musings from Dan Wood

Categories: Business · Mac OS X · Cocoa Programming · General · All Categories

Wed, 17 Jan 2007

Generating Standard Objects from Core Data Models

I recently had the occasion to create a number of cocoa classes. These ones were not using Core Data, but I thought it would be cool to make use of XCode's modeling tools and build up my objects as a Core Data model.

To accomplish this, I first ran across Jonathan 'Wolf' Rentzsch's mogenerator (installing by following this excellent tutorial).

mogenerator is little program that analyzes your data model and spits out classes (in two halves, a machine-generated part and a developer-modifiable part). But the classes that are generated are intended to be NSManagedObject subclasses, which I didn't want.

So I rebuilt the template files (which you install into ~/Library/Application Support/mogenerator/) to build instance variables, more standard accessors, an init and dealloc method, and so forth.

These files are available for download here. If you use it, you might want to modify these further, to change the accessor styles, replace NSMutableSet with NSMutableArray, and so forth. But it might be a useful start for your project.