views:

248

answers:

3

This is one of my favorite eclipse features. Does it exist in xcode? I'm getting tired of cutting and pasting from my header files in to my implementations.

+1  A: 

This is the kind of task that a user script is useful for. I use this one I banged out in ruby.

#! /usr/bin/env ruby -w


dash="------------------------------------"
r=/(^.+);/ # find entire function definition
pr=/(\w+(:|;))/ #find named parameters to make selector style string
s=STDIN.read
s.each_line() do |l|
  m=l.match(r)
  if m
    n=l.match(/:/) 
    if n  #if the function as one or more parameters
     params=l.scan(/(\w+:)/) 
     puts m.captures[0] + "{\n\n}//"+dash + params.to_s + dash +"\n\n"
    else #method has no parameters
      puts m.captures[0]+ "{\n\n}//"+dash + m.captures[0] + dash +"\n\n"
    end 
  end
end

To use, select a header method definition, run the script, switch to implementation and paste. This one adds in my preferred method comments boiler plate so you can customized that as you wish.

TechZen
Thanks TechZen. I'm looking for something even more streamlined, I think.
morgancodes
Actually, I'm working on something that will just take a single keystroke. It might be a couple of weeks though, I've got crawl under the hood in Xcode.
TechZen
+1  A: 

Check out Accessorizer, it may not be exactly what you're looking for, but it could help in other things that you may like. I haven't used it extensively yet, but I got it as part of one of MobileOrchard's bundle.

John Wang
+1 I was going to say this, although, personally, I just man up and do it the copy-paste way.
Abizern
+1  A: 

Take a look at the ODCompletionDictionary plug-in for Xcode. It allows you to define expandable macros that are configurable with many options. It is an enormous time saver.

Rob Keniger
Thanks Rob. I'll take a look.
morgancodes