How to fold and unfold a if condition, loops, any other code blocks within "{ code }" other than Methods body in XCode 9?

592 Views Asked by At

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.

1

There are 1 best solutions below

0
Rob On

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 ++.