Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idelovski

macrumors regular
Original poster
Sep 11, 2008
235
0
Hi,

I wanted to speed up creation of all the "alloc/init" lines I am putting into Xcode every day so I searched a while for some script that would do it for me.

I couldn't find anything so I started experimenting and with a little help of "Xcode Unleashed", page 227, I created this script:

Code:
#! /bin/sh
#
# Create nested allocation and initialization

echo -n "%%%{PBXSelectedText}%%%  *%%%{PBXSelection}%%% = [[%%%{PBXSelectedText}%%% alloc] init];"

In Xcode click on the Script menu and pick Edit User Scripts... command.

With this script ready, type some class name, select it and run the script. It will produce alloc/init sequence for given class.

For example, if you type NSString the script will produce NSString * = [[NSString alloc] init]; and put insertion point behind the asterisk where you can type your variable name.

I just hope someone may find this useful. if you have something similar please post it here.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.