ios开发--常用宏定义(部分转)
1、release时,屏蔽log
- #if defined (DEBUG) && DEBUG == 1
- #else
- #define NSLog(...) {};
- #endif
#if defined (DEBUG) && DEBUG == 1 #else
#define NSLog(...) {};
#endif
2、在主线程或在后台执行block
- #define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
- #define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
3、设备相关
- #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
- #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
- #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
- #define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])
- #define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion]) #define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
4、区分模拟器和真机
- #if TARGET_OS_IPHONE
- //iPhone Device
- #endif
- #if TARGET_IPHONE_SIMULATOR
- //iPhone Simulator
- #endif
#if TARGET_OS_IPHONE
//iPhone Device
#endif #if TARGET_IPHONE_SIMULATOR
//iPhone Simulator
#endif
5、根据是否使用ARC做不同操作
- #if __has_feature(objc_arc)
- //compiling with ARC
- #else
- // compiling without ARC
- #endif
ios开发--常用宏定义(部分转)的更多相关文章
- IOS开发常用宏定义
//release屏蔽NSLog//放在.pch文件里#ifdef DEBUG #else#define NSLog(...) {};#endif //G.C.D#define BACK(block) ...
- iOS开发——常用宏的定义
有些时候,我们需要将代码简洁化,这样便于读代码.我们可以将一些不变的东东抽取出来,将变化的东西作为参数.定义为宏,这样在写的时候就简单多了. 下面例举了一些常用的宏定义和大家分享: 1. 判断设备的操 ...
- iOS开发笔记--宏定义的黑魔法 - 宏菜鸟起飞手册
宏定义在C系开发中可以说占有举足轻重的作用.底层框架自不必说,为了编译优化和方便,以及跨平台能力,宏被大量使用,可以说底层开发离开define将寸步难行.而在更高层级进行开发时,我们会将更多的重心放在 ...
- iOS开发之--宏定义与const的区别及使用方法
宏定义的常见用法: 定义一段代码,或指定字符串抽成宏. const(常量): 当有字符串常量的时候,苹果推荐我们使用const,苹果经常把常用的字符串定义成const 宏定义与const的区别: 编译 ...
- iOS 开发常用宏
来源:iOS_小松哥 链接:http://www.jianshu.com/p/be00c3f3cafd 大家都是知道使用宏不仅方便,而且可以提高开发效率.下面总结了iOS开发过程中的一些常用宏,会持续 ...
- iOS之常用宏定义
下面我为大家提供一些常用的宏定义! 将这些宏定义 加入到.pch使用 再也不用 用一次写一次这么长的程序了 //-------------------获取设备大小------------------- ...
- Object-C开发常用宏定义
Object-C开发中宏会将经常用到的系统常量进行封装,方便使用: 1.获取通知中心 #define EYNotificationCenter(name, object, userInfo) [[NS ...
- ios 日常开发常用宏定义
#pragma mark - 字体.颜色相关 #define kFONT_SIZE(f) [UIFont systemFontOfSize:(f)] #define kFONT_BOLD_SIZE ...
- 李洪强iOS开发之宏定义方法来初始化一个单例对象
单例的使用: .m 为了方便实用,只要将以下代码定义在header文件或者.pch文件即可: // .h #define singleton_interface(class) + (instancet ...
随机推荐
- 关于MPEG2中的图像序列和图像组头GOP
图像序列 图像序列是由图像组构成的,是随机存取段落. sequence_header_code – The sequence_header_code is the bit string ‘000001 ...
- a mystrious max subquence sum
#include<cstdio>#include<cstring>const int maxn=100005;int buf[maxn];int main(){ freopen ...
- Microsoft Dynamics AX 2012 X++ Editor Extensions
Microsoft Dynamics AX 2012 X++ Editor Extensions Initial version of this project is based on the MSD ...
- select 嵌套查询
1. SELECT语句的子查询 语法: SELECT ... FROM (subquery) AS name ... 先创建一个表: CREATE TABLE t1 (s1 INT, s2 C ...
- App Naver Line 5.3 add new features - "True Delete"
Line is getting more and more popular in recent years. Lots of peope use Line, so do "Suspects& ...
- 二级路由器设置为何要关闭DHCP服务
因为如果不关闭dhcp的话会和一级路由相冲突,你这个因该是lan口的连接法吧,如果不然的话是不需要关闭dhcp功能的路由器和路由器的连接方法有两种,一种是wan口连,一种是lan口连方法1:WAN口连 ...
- 操作系统模仿CMD
实验一.命令解释程序的编写 专业:商软(2)班 姓名:列志华 学号:201406114254 一. 实验目的 (1)掌握命令解释程序的原理: (2)掌握简单的DOS调用方法: (3 ...
- 魔兽塔防游戏android源码
魔兽塔防是一款经典的游戏,当年在pc机器上玩过魔兽的人应该都玩过类似的游戏,他仿照魔兽,建塔拦截敌人入侵,发挥你的智慧让敌人走最远的路,将他们消灭在路上.... 源码下载:http://code.66 ...
- .net4.0注册到IIS
IIS和.netfw4.0安装顺序是从前到后,如果不小心颠倒了,无所谓. 打开程序-运行-cmd:输入一下命令重新注册IIS C:\WINDOWS\Microsoft.NET\Framework\v4 ...
- winform之回车执行某个按钮 以及Esc执行某个按钮
在winform中,我们在登陆的时候,需要点击回车键,就执行登陆,点击Esc键就执行取消,那么最方便的方法就是利用AcceptButton和CancelButton这两个属性(它属于窗体属性). 如图 ...