Cocoa folks: How would you indent this code?

One of the things that has bugged me about Cocoa is that the long method names and the de-facto indentation style (of lining up the colons in method invocations) conspire to create hard-to-read code with super long lines and sometimes weird indentation from Xcode.

For an example, see this little snippet of Objective-C:

Two problems:

  1. Some of the lines are really long and they wrap in a reasonable size window on my 15″ laptop screen.
  2. The indentation gets funky – e.g.: the “Do this other cool thing” button.

I don’t know how to make this code look good beyond doing uglyish things like doing the assignment separately from the type declaration or creating the button arguments beforehand and assigning them to variables. I hate to do something just to make the formatting look nice, although I’m tempted, because I don’t like the way this code looks.

How would you format this?

Leave a Reply

Your email address will not be published. Required fields are marked *