Functionize User Script

Here’s another user script I wrote to save time typing that didn’t make the Advanced Xcode lecture notes…

#!/usr/bin/env ruby do |line|
    puts line.rstrip.gsub(/\s*;/, " {\n\n}\n\n")

This script is intended to be used after copying method declarations from a header file into an implementation file. Once your method declarations are pasted into the .m file, simply select them and run the script. It will turn the declarations from this…

- (void)foo;
- (int)bar:(int)i;
- (IBAction)doSomething:(id)sender;
- (id)someReallyLongWindedMethod:(int)x
               thatSpansMultiple:(NSString *)y
                linesInTheHeader:(NSDictionary *)z;

…into stubbed out method implementations, like this…

- (void)foo {


- (int)bar:(int)i {


- (IBAction)doSomething:(id)sender {


- (id)someReallyLongWindedMethod:(int)x
               thatSpansMultiple:(NSString *)y
                linesInTheHeader:(NSDictionary *)z {


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: