IOS 常用的宏定义(一)
来源:互联网 发布:中易智联软件多少钱 编辑:程序博客网 时间:2024/04/30 15:59
1.设备的属性
#define isRetina ([UIScreen instancesRespondToSelect
#defineiPhone5 ([UIScreen instancesRespondToSelect
#defineisPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
#define SAFE_RELEASE(x) [x release];x=nil#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
2.GCD
#defineBACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#defineMAIN(block) dispatch_async(dispatch_get_main_queue(),block)
3.ARC
#if __has_feature(objc_arc)#else
#endif
4.判断是模拟器或者真机
#if TARGET_IPHONE_SIMULATOR
label.text =@"iphoneSimulator" ;
#elif TARGET_OS_IPHONE
label.text =@"iphoneDevice" ;
#endif
5.控件
#defineBARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLEstyle:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]
使用方法:
self.navigationItem.rightBarButtonItem =BARBUTTON(@"Action",@selector(action:));
6.function
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
#define VIEWWITHTAG(_OBJECT, _TAG) [_OBJECT viewWithTag : _TAG]
- IOS 常用的宏定义(一)
- iOS 常用的宏定义
- iOS 常用的宏定义
- ios 常用的宏定义
- iOS常用的宏定义
- iOS 常用的宏定义
- iOS 常用的宏定义
- IOS常用的宏定义
- ios常用的宏定义
- ios 常用的宏定义
- iOS 常用的宏定义
- IOS常用的定义
- IOS 常用宏定义
- iOS常用宏定义
- iOS 常用宏定义
- ios常用宏定义
- IOS 常用宏定义
- IOS常用宏定义
- POJ_2253(最短路问题变形)
- 使用Lua CJSON库进行encode与decode操作完成对Json数据转化
- HMM学习2之前向算法(转)
- poj 1144
- 受限的操作下迭代技巧之一道腾讯笔试题
- IOS 常用的宏定义(一)
- Java DataBase Connection
- 浏览器内核分析
- 日历函数
- C++中指针和引用的区别
- DB2 oralce mysql 取前十条记录对比
- 效率利器2-tmux
- Android Notes 00 - Services
- VC6.0用单文档调用对话框绘图