http://blog.sina.com.cn/u/2079395307  iphone和andorid开发博客

1.自定义DLog输出

#ifdef DEBUGLOG

#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

#else

#   define DLog(...)

#endif

2.判断设备ios版本

#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

3.判断设备是否支持retina

#ifndef ImageShowcase_Utility_h

#define ImageShowcase_Utility_h

#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen] currentMode].size) : NO)

#endif

4.适配iphone5的屏幕

//adaptive iphone5 macro

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhoneAppFrame [[UIScreen mainScreen] applicationFrame]

#define iPhoneScreenBounds [[UIScreen mainScreen] bounds]

5.Debug 标记

/*!

For debugging:

Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode).

Then go in the "Arguments" tab. You can add the following environment variables:

Default:   Set to:

NSDebugEnabled                        NO       "YES"

NSZombieEnabled                       NO       "YES"

NSDeallocateZombies                   NO       "YES"

NSHangOnUncaughtException             NO       "YES"

NSEnableAutoreleasePool              YES       "NO"

NSAutoreleaseFreedObjectCheckEnabled  NO       "YES"

NSAutoreleaseHighWaterMark             0       non-negative integer

NSAutoreleaseHighWaterResolution       0       non-negative integer

For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html

For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html

*/

6. ARC宏定义

#ifndef MB_STRONG

#if __has_feature(objc_arc)

#define MB_STRONG strong

#else

#define MB_STRONG retain

#endif

#endif

#ifndef MB_WEAK

#if __has_feature(objc_arc_weak)

#define MB_WEAK weak

#elif __has_feature(objc_arc)

#define MB_WEAK unsafe_unretained

#else

#define MB_WEAK assign

#endif

#endif

7.ARC (Automatic Reference Counting)

JMImageCache uses Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the -fobjc-arccompiler flag on all of the JMImageCache source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set -fobjc-arc for each of the JMImageCache source files.

ARC (Automatic Reference Counting)

JMImageCache uses Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the -fobjc-arccompiler flag on all of the JMImageCache source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set -fobjc-arc for each of the JMImageCache source files.

ARC (Automatic Reference Counting)

JMImageCache uses Automatic Reference Counting (ARC). If your project doesn't use ARC, you will need to set the -fobjc-arccompiler flag on all of the JMImageCache source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. In the "Compiler Flags" column, set -fobjc-arc for each of the JMImageCache source files.

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/zsw-1993/archive/2012/11/02/4880683.html

iphone 常用预编译代码相关推荐

  1. C/C++常用预编译指令介绍

    目录 1.#include指令 2.#define和#undef指令 3.#ifdef.#ifndef.#else.#elif和#endif指令 4.#error指令 5.编译器预置宏__FILE__ ...

  2. Emacs+hideif.el 隐藏预编译代码(或彩色显示预编译代码)

    什么是hideif 介绍一个Emacs自带的插件,位于emacs\lisp\progmodes\hideif.el,它能将代码中被#if 0-#else-#endif注释的无效代码,标记为自定义的格式 ...

  3. 【保姆级讲解】C语言---预编译处理精华

    预编译处理 1.1预编译处理概述 预编译处理也称为编译预处理,是在程序正式编译之前需要进行的前期编译处理阶段.主要作用是向编译器传递信息.以井号("#")开头的命令都是编译预处理命 ...

  4. 预编译指令与相关宏小结

    //======================================================================== //TITLE: //    预编译指令与相关宏小 ...

  5. 关于预编译和Stdafx.h的若干问题

    预编译 预编译头的概念: 所谓的预编译头就是把一个工程中的那一部分代码,预先编译好放在一个文件里(通常是以.pch为扩展名的),这个文件就称为预编译头文件这些预先编译好的代码可以是任何的C/C++代码 ...

  6. C++封装常用对象和对头文件以及预编译机制的探索

    在C++实际开发中,难免会使用到一些你极为常用的算法(比如笔者经常使用的多线程技术),实现这些算法的类或是全局函数或是命名空间等等经常都要被使用多次,你会有哪些办法来使用呢?笔者有4个办法. 第一个方 ...

  7. javascript代码块概念及预编译机制

    JavaScript是一种描述型脚本语言,它不同于java或C#等编译性语言,它不需要进行编译成中间语言,而是由浏览器进行动态地解析与执行.如果你不能理解javaScript语言的运行机制,或者简单地 ...

  8. python 预编译加速_让Python代码运行更快的最佳方式

    Python因其强大.灵活且易于使用等特性,而赢得了声誉.这些优点使其在各种各样的应用程序.工作流程和领域中得到了广泛应用.但是就语言的设计,也就是它天然的解释能力还有它的运行时的动态性而言,Pyth ...

  9. iphone常用代码锦集(二)

    详细内容 OpenGL 及 着色器语言 入门 详 详细内容 OpenGL教程三 增加投影和简单 详细内容 OpenGL教程二 添加着色器(sha 现在的位置: 首页 > 技术 > Ipho ...

最新文章

  1. 亿条数据读取工具_仅需1秒!搞定100万行数据:超强Python数据分析利器
  2. mosquitto 使用时出现的一些问题及其解决办法
  3. c语言编程单向链表排序,【分享】C语言 简单链表创建 排序 输出
  4. linux-free命令
  5. 深度剖析WinPcap之(九)——数据包的发送过程(8)
  6. html5怎么圆圈怎么打开,HTML5动感圆圈
  7. Gartner最新数据报告 WP系统仅剩1%
  8. Echarts初体验
  9. MySQL 引擎 阿里_MySQL引擎讲解-阿里云开发者社区
  10. [基础]全局组、域本地组、通用组的区别与联系
  11. c语言低级语言分为,认识C语言 -低级语言是什么?
  12. Nginx 配置学习
  13. 设计模式PHP篇(三)————适配器模式
  14. 如何用python写脚本_python写脚本
  15. C++ MFC 文字转语音
  16. 几道js数组循环练习题
  17. idea中没有 program arguments 选项
  18. 何晓理(风过无痕)-从85年开始的学习经历
  19. 获取微信昵称、头像等信息方法
  20. web服务器的作用!

热门文章

  1. 匿名内部类使用的场景之一
  2. 判断一个点是否在多边形区域内--C算法
  3. 经典算法学习——冒泡排序
  4. Remove Duplicates from Sorted List
  5. 交换机、路由器启动过程详述
  6. BZOJ3709: [PA2014]Bohater
  7. SQL 从一个表读取数据存到另一个表
  8. php 静态方法和非静态方法的调用说明
  9. 2015年9月百度前端在线笔试
  10. angular入门-ngOptions