Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to #pragma that work inside methods in Xcode 4

As mentioned elsewhere, #pragmas inside methods don't work in Xcode 4.

What's a good way to do quick navigation to different sections within a long method, for example to specific cases of a switch statement?

(I try to keep methods clean & short where practical, but that's a topic for elsewhere.)

like image 639
DenverCoder9 Avatar asked Oct 10 '22 09:10

DenverCoder9


1 Answers

Not sure if this is exactly what you are looking for... What I like to do is to simply use code blocks like so:

// some code

{
     // some code that should stay together
} // [a comment that explains what the code does]

This at least allows you to use Xcode's code folding: When you fold in the block between the two { }, you get {...} // [your explanatory comment]

It is also great to limit the scope of variables and can (very) slightly improve memory efficiency.

like image 96
mrueg Avatar answered Oct 18 '22 00:10

mrueg