Days Clear Information
#ifdef DEBUG
# define DLOG (FMT, ...) NSLog (@ "%s [line%d]" FMT), __pretty_function__, __line__, # #__VA_ARGS__);
#else
# define DLOG (...)
#endif
#if! DEBUG
#define NSLOG (...) {}
#else
#define NSLOG (...) NSLog (__va_args__)
#endif
System
#define Sys_version [[Uidevice currentdevice].systemversion Intvalue]
#define IS_IOS7 (sys_version >= 7.0)
#define IS_IOS8 (sys_version >= 8.0)
、
#define Screen_width [UIScreen mainscreen].bounds.size.width
#define Screen_height [UIScreen mainscreen].bounds.size.height
#define IPHONE6P ([uiscreen mainscreen].bounds.size.height = = 736.)
#define IPHONE6 ([uiscreen mainscreen].bounds.size.height = = 667.)
#define IPHONE5 ([uiscreen mainscreen].bounds.size.height = = 568.)
#define FITWIDTH (W) (Screen_ratio* (W))//Width according to 4.7-inch screen fitting
#define Fitheight (h) (screen_ratio_height* (h))//depending on the height of the 4.7-inch screen
#pragma mark-Global parameters
#define RGB (r,g,b) \
[Uicolor colorwithred: (R)/255.0f green: (G)/255.0f Blue: (B)/255.0f alpha:1]
#define RGBA (r,g,b,a) \
[Uicolor colorwithred: (R)/255.0f green: (G)/255.0f Blue: (B)/255.0f Alpha: (A)]
#define UICOLORFROMRGB (rgbvalue) [Uicolor colorwithred: ((float) ((Rgbvalue & 0xFF0000) >>))/255.0 Green: (( float) ((Rgbvalue & 0xff00) >> 8)/255.0 Blue: ((float) (Rgbvalue & 0xFF))/255.0 alpha:1.0]
/** 获取沙盒 Document 路径*/#define kDocumentPath [NSSearc#pragma mark - Check/** 字符串是否为空*/#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )/** 数组是否为空*/#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)/** 字典是否为空*/#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)/** 是否是空对象*/#define kObjectIsEmpty(_object) (_object == nil \ || [_object isKindOfClass:[NSNull class]] \ || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \ || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))hPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]/** 获取沙盒 temp 路径(注:iPhone 重启会清空)*/#define kTempPath NSTemporaryDirectory()/** 获取沙盒 Cache 路径*/#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]/** 获取程序包中程序路径*/#define kResource(f, t) [[NSBundle mainBundle] pathForResource:(f) ofType:(t)];#pragma mark - Base/** 弱引用*/#define kWeakSelf(type) __weak typeof(type) weak##type = type;/** 强引用*/#define kStrongSelf(type) __strong typeof(type) type = weak##type;/** 由角度转换弧度*/#define kDegreesToRadian(x) (M_PI * (x) / 180.0)/** 由弧度转换角度*/#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)
Common Macros for iOS development