Kevin Callahan has released a new version of Accessorizer — a Cocoa/Objective-C programmer's assistant that manages to be both a handy reference to the various accessor coding conventions and a productivity tool for doing real development.
You give it a list of instance variable declarations (either by selecing them in your source editor (e.g. Xcode) and invoking one of Accessorizer's convenient “Services” menu items, or by pasting or typing them into the Accessorizer window):
Accessorizer generates corresponding accessor method declarations:
and implementations:
that you can drop right into your source code. Just build, and go!
Accessorizer is savvy about protocol specifiers and the standard non-object types, and offers a host of options for customizing the code it generates both appearance-wise and in functionally significant ways. Have your setters no-op redundant sets or not. Have your getters [[... retain] autorelease] if that's your cup of tea. Have both take locks if you're writing a model class that needs to be thread-safe.
Accessorizer will even implement keyed archiving for you:
And for a multi-valued attribute...
...Accessorizer will obligingly furnish KVO-compliant indexed accessors at the click of a button:
For a really productive development experience, keep the Accessorizer window minimized in the Dock, and invoke its functionality via the Services menu. This allows you to stay within Xcode (or whatever source editing environment you use) the entire time. Just select your ivar declarations, invoke an Accessorizer service via its key equivalent (e.g. “Implementation”, Cmd+2), move the insertion point to where you want the result, and hit paste (Cmd+V).
In all it's a very nifty app that can save you lots of time and typing. What little tedium remains with the advent of Cocoa Bindings, Accessorizer largely eliminates. Check it out! Then buy Kevin a well-deserved beer! :-)
Links
Accessorizer's home page
Accessorizer's VersionTracker page