Pierre Bernard

My little hideout on the net

Xcode user script: PropertyFromInstanceVariable

Wrote some Perl today. No, I don't know Perl. Turns out it is good at handling strings.

I stumbled upon a blog post on Cocoa with Love. Matt Gallagher has devised this excellent Xcode user script to generate @property declarations and @synthesize statements from variable declarations. This is triple great:

1. The script will save me quite some typing
2. I had never noticed the Xcode script menu
3. Matt found a nifty way around limitations of those user scripts

So I grabbed the script. Installed it. Then I figured, I could improve upon the existing script. My changes include:

1. Generates the necessary statements in the dealloc method
2. Detects variable types and tries to be smart about setter semantics
3. Supports underbar variable names

Shortly after I had published my version of the code to my own Code page, Mike Schrag pointed me to his forked version of Matt's script. He had made many of the same enhancements. Moreover he had taught the script to handle multiple varaibles in one pass.

Merging my version and Mike's I created my very first project on github. The new version improves on Mike's by reducing the number of calls to AppleScript. It retains all my previous enhancements. And hopefully also retains Mike's changes. It is available on github, as well as on my own Code page. Enjoy!
Comments (1)