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

STDIN.read.each do |line|
    puts line.rstrip.gsub(/\s*;/, " {\n\n}\n\n")
end

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 {

}
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: