Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's one I wrote up yesterday to do the @property directives before coming across this question a few hours later. It's a simple text filter and would be trivial to extend it to @synthesize directives (add an appropriate <code>when</code> clause to the <code>case</code> statement and make appropriate additions to the <code>when block_end</code> condition), and not much more work to extend it to handle multiple occurrences of @interface/@implementation in one file (by tracking their names --- it can be done through regexp captures, as everything else is in the script):</p> <pre><code>#! /usr/bin/ruby # -------------- Basic Definitions ----------------------------- doc = "%%%{PBXFilePath}%%%" # regular expressions search_exp = /[[:space:]]*([[a-zA-Z0-9]]*)[[:space:]]\*([a-zA-Z0-9]*)/ interface_start = /@interface/ block_end = /^\}/ #initializing variables properties_list = [] properties_string = "" reading_interface = 0 #---------------- Start Processing ----------------------------- file = File.open(doc, "r").readlines file.each do |line| # capture the regular expression matches only in the # interface declaration and print out the matching # property declarations case line # start capturing when interface_start reading_interface = 1 puts line # capture and keep in properties_list when search_exp if (reading_interface == 1) then data = Regexp.last_match properties_list &lt;&lt; data end puts line # unpack properties_list and print out the property # declarations when block_end if (reading_interface == 1) then reading_interface = 0 properties_list.each do |pair| properties_string &lt;&lt; "@property (readwrite, copy) #{pair[0].lstrip};\n" end puts line puts "\n" + properties_string end else puts line end end </code></pre> <p>I run this using "no input" and "replace document contents" as the options for I/O in the User Scripts editor.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload