Recently, I have updated my Xcode from version 8 to version 9. but now I face a weird issue and that is code folding ribbon. New version (9) doesn't having such thing in it. After research a lot I find out the way of folding the code but still it works only for methods(that is press & hold ⌘ key + hover mouse over the opening or closing of methods braces +single tap popup + fold). but I need to fold every code block that inside the open '{' and close '}' braces i.e. if, else ,loops, objective c blocks class etc.
Asked
Active
Viewed 538 times
3
-
1The other approach is to use the keyboard short cut ⌥ + ⌘ + ←. But In Objective-C is doesn't fold within `{` and `}`, just functions. It works in Swift, but not Objective-C. – Rob Jan 25 '18 at 07:31
-
sorry this is not right – Ravi Raja Jangid Jan 25 '18 at 20:36
-
What do you mean "this is not right"? I use it all the time for folding individual methods. – Rob Jan 25 '18 at 20:37
-
sorry @Rob this is not what I want. I want to fold individuals if or loops or blocks within method body, but your answer folding the whole function. – Ravi Raja Jangid Jan 25 '18 at 20:41
-
Understood. But like I said, Xcode 9 does not, at this point, support folding of loops or blocks within Objective-C. In Objective-C, it folds entire methods only. It only supports block-level folding in Swift code. So, you might not like it, but it is what it is. – Rob Jan 25 '18 at 20:42
1 Answers
2
I understand you want to fold the {...}
clauses in Objective-C, but Xcode 9.2 does not do that.
Code folding has undergone some evolution in Xcode 9. Apple completely rewrote the editor in Xcode 9 and code folding was largely broken in Xcode 9.0. As of Xcode 9.2 (and Xcode 9.3 beta), it supports folding of entire methods, but does not support code folding of individual Objective-C {...}
blocks (e.g. if
, while
, etc.). For Objective-C, Xcode only does code folding at the method-level.
Xcode does support folding of {...}
blocks in Swift code, but not in Objective-C.
FYI, a less cumbersome approach for code folding is to use the keyboard shortcut ⌥+⌘+←.

Rob
- 415,655
- 72
- 787
- 1,044