Objective-c code formatting

what would be a good way to format this piece of code?

UIBarButtonItem *prev = [[UIBarButtonItem alloc] initWithTitle:@"Prev"
                        style:UIBarButtonItemStyleBordered
                        target:self
                        action:@selector(setDateRangeClicked:)];
+3
source share
3 answers

Taking a question with a different meaning, the best way to format this code is to use Xcode.

Select the code for formatting, then in Edit → Format → Re-Indent, and you will get the code in the standard Xcode format.

I matched it with the keyboard shortcut alt-cmd- [since I was used for TextMate. He was buried under many menus, so a keyboard is convenient for this. If you use TextMate, click inside the block to format and press ctrl-Q. However, TextMate has some problems with this formatting style.

+3
source

, , , . :

UIBarButtonItem *prev;
prev = [[UIBarButtonItem alloc] initWithTitle:@"Prev"      
                                        style:UIBarButtonItemStyleBordered
                                       target:self
                                       action:@selector(setDateRangeClicked:)];

, .

+5

.

(1) " : []" " " "" Xcode.

(2) <tab> .

, . . . :

  • " " "lt; tab" ,

  • Xcode , , .

Any number of people will argue about any number of very specific formatting rules. All is well and good, but ultimately, letting the tools do all the work, will reduce the time and increase the number of problems that the tools will automatically detect.

You are still responsible for inserting into new lines where you find them aesthetically pleasing.

+5
source

Source: https://habr.com/ru/post/1729015/


All Articles