必赢的网址登录 > 必赢网址 > iOS开发常用的宏

原标题:iOS开发常用的宏

浏览次数:65 时间:2019-10-01

#define kScale ([UIScreen mainScreen].bounds.size.width)/320#define StatusBar_HEIGHT 20 //状态栏高度#define NavigationBar_HEIGHT 44 //导航条高度#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) //屏幕宽度#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)//屏幕高度#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] //系统版本-float#define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion]) //系统版本-string#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0]) //系统语言#define kWindow [[UIApplication sharedApplication] keyWindow]#ifdef DEBUG# define XHLog NSLog((@"%s [XH %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);#else# define XHLog#endif#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake, [[UIScreen mainScreen] currentMode].size) : NO)#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)#define isiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)#if TARGET_OS_IPHONE//iPhone Device#endif#if TARGET_IPHONE_SIMULATOR//iPhone Simulator#endif//ARC#if __has_feature//compiling with ARC#else// compiling without ARC#endif//G-C-D#define GCDBACK dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)#define GCDMAIN dispatch_async(dispatch_get_main_queue#define kWS __weak __typeof(&*self)weakSelf = self;#define kWeakObj __weak typeof#ifndef weakify#if DEBUG#if __has_feature#define weakify autoreleasepool{} __weak __typeof__ weak##_##object = object;#else#define weakify autoreleasepool{} __block __typeof__ block##_##object = object;#endif#else#if __has_feature#define weakify try{} @finally{} {} __weak __typeof__ weak##_##object = object;#else#define weakify try{} @finally{} {} __block __typeof__ block##_##object = object;#endif#endif#endif#ifndef strongify#if DEBUG#if __has_feature#define strongify autoreleasepool{} __typeof__ object = weak##_##object;#else#define strongify autoreleasepool{} __typeof__ object = block##_##object;#endif#else#if __has_feature#define strongify try{} @finally{} __typeof__ object = weak##_##object;#else#define strongify try{} @finally{} __typeof__ object = block##_##object;#endif#endif#endif#pragma mark - 是否为空或是[NSNull null]#define kNotNilAndNull  != nil) &&  isEqual:[NSNull null]]))#define kIsNilOrNull  == nil) ||  isEqual:[NSNull null]]))#pragma mark - 图片资源获取#define kIMGFROMBUNDLE [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:X ofType:@""]]#define kImageNamed [UIImage imageNamed:X]#define USER_DEFAULT [NSUserDefaults standardUserDefaults]#define DECLARE_SINGLETON(cls_name, method_name)+ (cls_name*)method_name;#define IMPLEMENT_SINGLETON(cls_name, method_name)+ (cls_name *)method_name {static cls_name *method_name;static dispatch_once_t onceToken;dispatch_once(&onceToken, ^{method_name = [[cls_name alloc] init];});return method_name;}#define L NSLocalizedString#define EMPTY_STRING ( [string isKindOfClass:[NSNull class]] || string == nil || [string isEqualToString:@""])#define GET_STRING (EMPTY_STRING ? @"" : string)#define OBJC_STRINGIFY @#x#define encodeObject [aCoder encodeObject:x forKey:OBJC_STRINGIFY]#define decodeObject x = [aDecoder decodeObjectForKey:OBJC_STRINGIFY]#define encodeBool [aCoder encodeBool:x forKey:OBJC_STRINGIFY]#define decodeBool x = [aDecoder decodeBoolForKey:OBJC_STRINGIFY]#define encodeInt [aCoder encodeInt:x forKey:OBJC_STRINGIFY]#define decodeInt x = [aDecoder decodeIntForKey:OBJC_STRINGIFY]#define encodeDouble [aCoder encodeDouble:x forKey:OBJC_STRINGIFY]#define decodeDouble x = [aDecoder decodeDoubleForKey:OBJC_STRINGIFY]

本文由必赢的网址登录发布于必赢网址,转载请注明出处:iOS开发常用的宏

关键词:

上一篇:但不光只是解答难题,日常说的block无法改变一些

下一篇:没有了