Xcode replace old style code to new style

Assume you have

[personData setValue:someProperty forKey:someKey]

and you want to change that to

personData[someKey] = someProperty

…and that for about 100 lines ?

Easy! Just type Find (cmd-f in your Xcode, change it to replace, then click on the magnifying glass and select edit find options, and then regular expression for “matching style”. Then type in

Find: \[(.*) setValue:(.*).*forKey:(.*)\];

Replace: $1[$3] = $2;

The ()-part in the find finds the first text addressed by $1, the second ()-part is addressed later by $2

You gotta love regular expressions!

China Domain name registration scam

In the past years, we received at least once a year an email where some nice registration company from china asks us if we would mind, if some client of theirs would register the domain small-apps.cn. Today was the day for 2016.

Let me tell you that registering your domain name in china is easy and cheap – about 12-20 $/€ a year I read in a price list of nicenic.net. German reseller companies offer it for 60€/year.

Swift code comment special words

Swift can help you a lot to document your code – it allows you to use markup. However, in order to use it not only as formatted text but as source code commentary, it is nice to use the special keywords known.

I created my own cheat sheet for these keywords, which create their own left column or blocks. Always use them with a preceding minus, like this

– returns: the object or nil, if not successful

  • returns:
  • throws:
  • parameter <param>:
  • parameters:
    • <param1>:
    • <Param2>:

You can also use the following keywords to have bold text formatted inside the description block:

  • Author:
  • important:
  • version:
  • Attention:
  • todo:

For more keywords, see the reference, linked above.