Playing with Core Data
Originally posted 2005-11-24 10:50:32
I continue to delude myself into believing that I’m going to learn Objective-C and Cocoa. My bookshelf droops like a swaybacked cayuse with all the Cocoa and Objective-C books I’ve purchased (side note: they all seem more folksy than technical, demonstrating that the artsy culture must permeate everything Apple). I’ve leapt from the object.method syntax to [object message]. I’m coming to grips with creating live objects in a binary file during development, although I still prefer doing such things in code (even simple GUI builders make me nervous these days). After a 6-year hiatus from C++ and COM, spent basking in Java’s garbage collection, I’m maneuvering release rules and reference counting. I even added a patch to the excellent iTerm (it’s the one that adds a keystroke to toggle transparency, if you must know, but it missed the 0.8.1 release).
With all this going for me, what’s the problem? Why do I call my quest a delusion? Simply this: my current life circumstances allow me to spend 15 minutes a week on learning Objective-C, in three 5-minute snatches, each of which must occur during a bout with insomnia. Not encouraging. Still, I dutifully download and install the latest versions of Xcode and gaze longingly at those lovely Cocoa titles as they progressively warp my bookshelf. \”It’ll happen,\” I keep telling myself. So, when I saw that Xcode 2.2 had been released, I downloaded, installed, and fired it up. My first thought was to play with a new feature released with Tiger that I hadn’t looked at yet: Core Data.
Overshadowed by Dashboard, Spotlight, and Automator, Tiger’s new Core Data feature provides developers a sophisticated data layer for Cocoa applications. You can read more about it here. For my 5-minute session, I launched the Data Model Design tool and started playing. Immediately, I felt like a data architect. No, the Data Model tool isn’t ERwin, but no company I’ve worked for has yet paid to drop that onto my desktop. But here I was, creating tables and attributes and relationships, tying an entire data model together visually. As I read the documentation, Core Data performs all the Object-Relational mapping, and code and model automatically stay in sync. Who needs Hibernate?
Here’s a picture:
Maybe I’ll actually build an application using Core Data . . . in 5 minute increments . . . I gotta believe.