原帖地址:http://macdevelopertips.com/xcode/xcode-and-pragma-mark.html

I’ve started using #pragma mark directives in my code to help with organization as my implementation files grow. #pragma mark is simple to use, for example, insert the following to call out initialization code:

#pragma mark -
#pragma mark Initialization

Once this is in place, the Functions Menu (in the navigation bar) which shows a list of locations within a source file (e.g. definitions of classes, functions and methods) will display a new marker with the label “Initialization.” The code in line 1 will add a line separator inside the Functions Menu, in this example, with the line appearing above the “Initialization” marker.

The figure that follows shows an example of how you might use #pragma mark to divide up various sections of your code.

Two notes:

  • You cannot have a space after the “-” in the #pragma mark –
  • If your code does not appear as expected (e.g. the separator does not appear), check that ‘Sort list alphabetically’ is not checked in the Code Sense preference settings.

Xcode and #pragma mark的更多相关文章

  1. android studio: 实现类似于XCode中的#pragma mark的效果

    代码行数写多了,想找一个指定的方法真困难,关键有时候记不住方法的名字,用Ctrl+O也不好使,突然想到以前做iOS开发时,XCode里有一个#pragma mark的功能,很好用:在代码中定义这样一个 ...

  2. 从Objective-C到Swift,你必须会的(一)#pragma mark

    在Objective-C里,为了让代码组织的有序也方便用control+6的快捷键在Xcode中查找,所以出现了一个大家都很熟悉的东东.这就是:#prama mark. #pragma mark  但 ...

  3. 善用#waring,#pragma mark 标记

    在项目开发中,我们不可能对着需求一口气将代码都写好.开发过程中肯定遇到诸如需求变动,业务逻辑沟通,运行环境的切换等这些问题.当项目大的时候,如果木有形成统一的代码规范,在项目交接和开发人员沟通上将会带 ...

  4. #pragma mark指令

    1.#pragma mark指令的使用 功能:简单来说就是对代码的分组,方便代码查找和导航用的 它们告诉Xcode编译器,要在编辑器窗格顶部的方法和函数弹出菜单中将代码分隔开.一些类(尤其是一些控制器 ...

  5. layoutSubviews #pragma mark -

    >>>layoutSubviews: layoutSubviews是对sbuviews的重新布局,比如,我们想更新子视图的位置,可以通过调用layoutSubviews方法(不能直接 ...

  6. pragma mark - 合成图

    #pragma mark - 合成图 - (UIImage *)getShareImageShell:(UIImage *)shareImage { if (shareImage) { CGSize ...

  7. IOS笔记 #pragma mark的用法和作用(方便查找和导航代码)

    简单的来说就是为了方便查找和导航代码用的.   下面举例如何快速的定位到我已经标识过的代码.     #pragma mark 播放节拍器 - (void) Run:(NSNumber *)tick{ ...

  8. 李洪强iOS开发之OC[015]#pragma mark的使用

    // //  main.m //  14 - #pragma mark的使用 // //  Created by vic fan on 16/7/10. //  Copyright © 2016年 李 ...

  9. IOS笔记 #pragma mark的用法

    简单的来说就是为了方便查找和导航代码用的. 下面举例如何快速的定位到我已经标识过的代码. #pragma mark 播放节拍器 - (void) Run:(NSNumber *)tick { //.. ...

随机推荐

  1. iOS下JS与OC互相调用(五)--UIWebView + WebViewJavascriptBridge

    WebViewJavascriptBridge是一个有点年代的JS与OC交互的库,使用该库的著名应用还挺多的,目前这个库有7000+star.我去翻看了它的第一版本已经是4年前了,在版本V4.1.4以 ...

  2. C在控制台上实现鼠标画图功能

    #include <windows.h> #include <stdio.h> #include <string.h> HANDLE hOut; HANDLE hI ...

  3. 5、Android Service测试

    如果你在应用中使用了Service,你应该来测试这个Service来确保它正常工作.你可以创建仪表测试来验证Service的行为是否正确:比如,service保存和返回有效的数值并正常的处理数据. A ...

  4. linux shell bash使用管道|和read结合时问题解决

    最近在将ksh转成bash运行的时候出现了问题.代码如下: echo $1 | sed 's/\..*$/''/' | read FILE_NAME 当使用ksh执行的时候没有问题,FILE_NAME ...

  5. 通过一个color创建一个image

    使用的地方: [_addButton setBackgroundImage:[UIImage imageWithColor:[[UIColor whiteColor] colorWithAlphaCo ...

  6. Cocos2D瓦块地图高清屏(retina)显示比例问题的解决

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 在Cocos2D的游戏编程里,常用到瓦块地图.而cocos2D ...

  7. ubuntu和mac OS X下另一种使用QQ的方法

    在ubuntu可以到pidgin官网下载http://www.pidgin.im,然后再安装插件 pidgin-lwqq即可,步骤为: sudo add-apt-repository ppa:lain ...

  8. 【linux学习笔记】Sublime Text3支持GB2312和GBK编码以及中文输入法

    几天在ubuntu15.10下使用Sublime Text3发现中文乱码,以及不能使用中文输入法(搜狗输入法linux版)的问题,捣鼓了半天,终于完善了,下面po一下我的解决方案. 一.支持GB231 ...

  9. CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤

    准备文件如下: 1.CentOS-6.4-x86_64-bin-DVD1.iso 2.jdk-7u67-linux-x64.rpm 3.apache-tomcat-7.0.55.tar.gz 安装步骤 ...

  10. Windows2003下用Dreamweaver打开CodeSmith文件设置办法

    .在第一行的ASP,字符串后面添加CST,2.找到行ASP,ASA:ActiveServer Pages修改为ASP,ASA,CST:ActiveServer Pages 二.用记事本打开文件2:C: ...