Quantcast
Channel: Inchoo » Ivan Kalaica
Viewing all articles
Browse latest Browse all 24

What is a #pragma mark?

$
0
0

One of many features in Xcode that developers forgot to use is #pragma mark directives. What is a #pragma mark? #pragma marks are simple directives that help us better organize our implementation code.

When you are using #pragma mark directives in implementation code, you are in one way adding titles for one or more segments of your code in Functions Menu. This is very useful feature, because in the end, your code (your list of your method definitions) looks neater and more organized. For example, if you put #pragma mark Private methods in your implementation code right above -(void) initUI{ } method, then the Functions Menu (in the navigation bar) will show Private methods for that definition and for any other definition you define or group together with -(void) initUI{ } method.

If you have problem with #pragma mark appearance (sections are not in array as you define), ensure that Sort List Alphabetically is not checked in the Code Sense preference settings. While this feature may be less necessary in smaller applications, when you have application with classes with more the ten method definitions, it’s a very good idea to use #pragma mark directives.


Viewing all articles
Browse latest Browse all 24

Trending Articles