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])

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容