Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 4, 2009, 04:42 PM   #1
idelovski
macrumors regular
 
Join Date: Sep 2008
Useful script for Xcode - alloc and init

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.
idelovski is offline   0 Reply With Quote
Old Feb 4, 2009, 04:53 PM   #2
MacRohde
macrumors regular
 
Join Date: Jun 2004
Location: Copenhagen, Denmark
Hey that is pretty cool. I will check it out when I get home. Thanks for the contribution
__________________
My main systems: iMac 2.7 GHz (Mountain Lion), iPad 2, iPhone 4S.
MacRohde is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
WHERE TO INIT a CLASS joak iPhone/iPad Programming 8 Mar 20, 2014 11:23 AM
Resolved: No known class method for selector 'alloc' ? ArtOfWarfare Mac Programming 14 Jan 8, 2014 02:20 PM
Resolved: ARC, @property, alloc/init larswik iPhone/iPad Programming 5 Aug 25, 2013 06:36 PM
When to use [[alloc]init] Branda22 iPhone/iPad Programming 20 Jun 26, 2013 02:45 PM
Silly question about alloc/init for UILabel animefx iPhone/iPad Programming 1 Jul 14, 2012 01:53 AM

Forum Jump

All times are GMT -5. The time now is 05:07 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC