IOS the development of commonly used macros

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
  1 #define NavigationBar_HEIGHT 44
  2 
  3  
  4 
  5 #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
  6 
  7 #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
  8 
  9 #define SAFE_RELEASE(x) [x release];x=nil
 10 
 11 #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
 12 
 13 #define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])
 14 
 15 #define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
 16 
 17  
 18 
 19 #define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]
 20 
 21  
 22 
 23  
 24 
 25  
 26 
 27 //use dlog to print while in debug model
 28 
 29 #ifdef DEBUG
 30 
 31 #   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
 32 
 33 #else
 34 
 35 #   define DLog(...)
 36 
 37 #endif
 38 
 39  
 40 
 41  
 42 
 43 #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
 44 
 45 #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
 46 
 47 #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
 48 
 49  
 50 
 51  
 52 
 53 #if TARGET_OS_IPHONE
 54 
 55 //iPhone Device
 56 
 57 #endif
 58 
 59  
 60 
 61 #if TARGET_IPHONE_SIMULATOR
 62 
 63 //iPhone Simulator
 64 
 65 #endif
 66 
 67  
 68 
 69  
 70 
 71 //ARC
 72 
 73 #if __has_feature(objc_arc)
 74 
 75 //compiling with ARC
 76 
 77 #else
 78 
 79 // compiling without ARC
 80 
 81 #endif
 82 
 83  
 84 
 85  
 86 
 87 //G-C-D
 88 
 89 #define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
 90 
 91 #define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
 92 
 93  
 94 
 95  
 96 
 97 #define USER_DEFAULT [NSUserDefaults standardUserDefaults]
 98 
 99 #define ImageNamed(_pointer) [UIImage imageNamed:[UIUtil imageName:_pointer]]
100 
101  
102 
103  
104 
105  
106 
107 #pragma mark - common functions
108 
109 #define RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }
110 
111  
112 
113  
114 
115 #pragma mark - degrees/radian functions
116 
117 #define degreesToRadian(x) (M_PI * (x) / 180.0)
118 
119 #define radianToDegrees(radian) (radian*180.0)/(M_PI)
120 
121  
122 
123 #pragma mark - color functions
124 
125 #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
126 
127 #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
128 
129 
130 
131    
132 
133  

 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Bartholomew at November 16, 2013 - 2:31 AM