iOS开发常用的宏

1.debug模式和release模式的NSLog打印

#ifdef DEBUG
#define LRLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define LRLog(...)#endif

2.弱引用/强引用

#define YSWeakSelf(type) __weak typeof(type) weak##type = type;
#define YSStrongSelf(type) __strong typeof(type) type = weak##type;

3.判断真机还是模拟器

#if TARGET_OS_IPHONE //iPhone Device 
#endif 
#if TARGET_IPHONE_SIMULATOR //iPhone Simulator 
#endif

4.沙盒目录文件

//获取temp
#define kPathTemp NSTemporaryDirectory()
//获取沙盒 Document#define kPathDocument 
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache#define kPathCache 
[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

你可能感兴趣的:(iOS开发常用的宏)