Xcode user script to create a property from an ivar
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Xcode property from ivar

This is 99.9% the very handy script from Cocoa with Love . All that I’ve added is support for underscore naming of ivars (which will generate a synthesize with an alias), an explicit “assign” declaration for non-pointer types (just because I like it), and generation of a release in the dealloc method (or a new dealloc method if there isn’t one already) for pointer types.

Installation Instructions

  1. Open Xcode, go to Scripts menu, select Edit User Scripts
  2. Add a new shell script (I put it under the “Code” section)
  3. Double-click the name to change it (“Generate Property” is what I use)
  4. Double-click the cmd column to set a hotkey (cmd-shift-p is what I use — I had to restart for this to be picked up)
  5. Select “Entire Document” for Input
  6. Select “Home Directory” for Directory
  7. Select “Discard Output” for Output
  8. Select “Display in Alert” for Errors
  9. Clear out the existing script
  10. Paste the contents of PropertyFromInstanceVariable.pl into the script area

Usage Instructions

  1. Go to an ivars block and type NSString *_name; (or whatever your declaration might be)
  2. Triple click the ivar line (to select the entire line)
  3. Run the “Generate Property” script (cmd-shift-p, or run it from the menu)
  4. Thank Matt Gallagher