Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code format helper?

Tags:

xcode

Would like to ask is there a tool in xcode whereby it will check the code format and restructure it in such a way that its much more presentable? Sort of indenting helper, I suppose?

For example

            -(void)someMethod {
    switch(obj.someString)
{
...
}
}

Is there a helper to change it to

    -(void)someMethod {
    switch(obj.someString)
    {
         ...
    }
}

also when the codes get really long, I want to break them down into different rows.

string = @"example1"; string2 = @"example2"; string3 = @"example3" ...; 
like image 268
Gavin Avatar asked Mar 20 '26 05:03

Gavin


1 Answers

i typically use astyle and uncrustify. both are open.

they each have a ton of options. they can add or remove spaces/braces/lines, pad, split, indent, hard wrap, force tab or space indentation and much more.

assuming you have macports, drop this into your terminal to install:

sudo port install astyle

sudo port install uncrustify

since both programs support multiple languages: you will probably want to use uncrustify for objc.

like image 86
justin Avatar answered Mar 22 '26 02:03

justin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!