4

I have a class which has all methods public. Today I decided to remove some of the methods that I don't need anymore, so I started to clean-up my .m file.

Now I would like to generate method declarations for my methods from .m to header file. I have started to copy-paste all lines, deleting implementation and adding ; at the end, but we live in XXI century and there might be some tools that may do that for me.

Is there any quick way to do that in AppCode and/or XCode? I heard something about accessorizer, but this tool is paid and I can't test it.

[EDIT]

I have found application called Accessorizer: http://www.kevincallahan.org/software/accessorizer.html but it's paid and I cannot check if it will solve my problem.

Szu
  • 2,254
  • 1
  • 21
  • 37
  • Not sure if there is a way in Xcode, but you could write your own program/script that parses the file and auto-generates the header lines. A simple regex match algorithm should do the trick. – carloabelli Jul 09 '14 at 13:33
  • @trojanfoe I don't change accessibility of my methods. I just remove some of them from .m file and want to do the same from .h file. – Szu Jul 09 '14 at 13:48
  • @cabellicar123 I thought about that. – Szu Jul 09 '14 at 13:49

2 Answers2

2

AppCode has many interesting features to ease such things.

You can expose a method by using alt-enter on it:

enter image description here

You can also call a private (non exposed) method, and it will propose you to expose it. (alt-enter on highlighted error)

I often do the opposite, "programming by intuitions" as they call it. First write a call the method that does not exist and it will propose you to create a stub of it (with .h/.m declaration)

Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56
2

For those who do not use AppCode this bash script might help:

#!/bin/bash

if [[ -z "$1" ]]; then
    echo "Usage $0 file"
    exit 1
fi

while read -r line; do
    if [[ "$line" =~ (\+|-)\ ?\( ]]; then
        echo "${line% {};"
    fi
done < $1
carloabelli
  • 4,289
  • 3
  • 43
  • 70