ios开发常用宏

/** 屏幕宽度 */

#define eDeviceWidth [UIScreen mainScreen].bounds.size.width

/** 屏幕高度 */

#define eDeviceHeight [UIScreen mainScreen].bounds.size.height

/** 设置NSUserDefaults单例 */

#define eUserDefaults [NSUserDefaults standardUserDefaults]

/** 设置NSNotificationCenter单例 */

#define eNotificationCenter [NSNotificationCenter defaultCenter]

/** 打印 */

#define NSLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);

/** 系统版本 */

#define eSystemVersion  [[[UIDevice currentDevice] systemVersion] floatValue]

/** 随机颜色 */

#define eRandomColor [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0 blue:arc4random() % 255 / 255.0 alpha:1]

/** 字体大小 */

#define eFont(s) [UIFont systemFontOfSize:s]

/** 弱引用声明 */

#define __eWeak(weakSelf)  __weak __typeof(&*self)weakSelf = self

/** 手机唯一标识符UUID */

#define eDeviceUuid [[[UIDevice currentDevice] identifierForVendor] UUIDString]

/** 初始化UIImage */

#define eImageName(name) [UIImage imageNamed:name]

/** 格式化字符串 */

#define eFormatterString(s,...) [NSString stringWithFormat:@"%@",([NSString stringWithFormat:(s), ##__VA_ARGS__])]

/** 获取AppDelegate */

#define eAppDelegate  ((AppDelegate *)[UIApplication sharedApplication].delegate)

/** 设置UITableViewCell的Identifier */

#define eIdentifiers(className) NSStringFromClass([className class])

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏,会持续的往里面添加。 /...
    MTDeveloper阅读 160评论 0 0
  • //字符串是否为空#define kStringIsEmpty(str) ([str isKindOfClass:...
    hj_Ma阅读 134评论 1 0
  • www.dletc.com.cn 大家都知道使用宏不仅方便,而且可以提高开发效率。下面小卓君搜罗了一些iOS开发过...
    大连中软卓越阅读 288评论 0 0
  • iOS开发过程中,使用的一些常用宏定义 字符串是否为空#define kStringIsEmpty(str) ([...
    goyohol阅读 5,397评论 30 85
  • 今天抽到的是星币一正位 开始抽到权杖的正位了,说明我的行动开始了,我昨天投的简历也许还没奏效,但是至少这是一个好的...
    塔罗师cat阅读 152评论 0 0