Does Xcode support anything akin to Visual Studio style #region
directives for arbitrary code folding?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- Popover segue to static cell UITableView causes co
- “Storyboard.storyboard” could not be opened
I am going to hell for this but here goes:
At the top of a given file, put
Wherever you want to fold something, wrap it in an if block like so:
That will let you fold it away out of sight.
Put your desired code inside brackets { }, and it will become a folding zone.
But you have to keep in mind that brackets also define variables scope, so this code should not have variables declarations which will be used outside these brackets.
One nice solution I just found:
Put your project into one big namespace. Close and reopen this namespace for the individual sections of your source file:
Try this way :
It can do like that :
Without support for .Net style regions, being able to collapse all your functions at the same time is the next best thing.
command-option-shift-left arrow to collapse all.
command-option-shift-right arrow to expand all.
Xcode will remember the last state of collapsed functions.
That won't work in the place you want it most, that is, around groups of functions or methods.
It may be useful inside a long, linear method with no internal conditionals or loops, but such methods aren't common in general Mac OS X UI code, though if you're writing some big numeric or graphics-crunching code it could help group things.
And the if(fold) is entirely superfluous. Just use the braces inside a method or function and Xcode will fold them.