iOS 常用的宏

#pragma mark -NSUserDefaults

#define NSUserDefaults                                    [NSUserDefaults standardUserDefaults]
#define Synchronize                                       [NSUserDefaults synchronize]
#define NSUserDefaults_BoolForKey(_KEY_)                  [NSUserDefaults boolForKey:_KEY_]
#define NSUserDefaults_ObjectForKey(_KEY_)                [NSUserDefaults objectForKey:_KEY_]
#define NSUserDefaults_SetBoolForKey(_BOOL_, _KEY_)       [NSUserDefaults setBool:_BOOL_ forKey:_KEY_]
#define NSUserDefaults_SetObjectForKey(_OBJECT_, _KEY_)   [NSUserDefaults setObject:_OBJECT_ forKey:_KEY_]

#pragma mark -Keys for NSUserDefaults

#define VERSION_THELAST_EXISTS @"Version_370_Exists"






#pragma mark -Device Size

#define NavigationBar_HEIGHT  44
#define SCREEN_WIDTH         [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT        [UIScreen mainScreen].bounds.size.height
#define SCREEN_BOUNDS        [[UIScreen mainScreen]bounds]

#pragma mark -CGMake
#define Point(x,y)           CGPointMake(x, y)
#define Size(w,h)            CGSizeMake(w, h)
#define Rect(x,y,w,h)        CGRectMake(x,y,w,h)



#pragma mark -NSLog

#ifdef DEBUG
#   define NSLog(fmt, ...)    NSLog((fmt),##__VA_ARGS__)
#else
#   define NSLog(...)
#endif


#pragma mark -Return NSObject
#define String(fmt, ...)    [NSString stringWithFormat:(fmt),##__VA_ARGS__]
#define URL(fmt, ...)       [NSURL URLWithString:String((fmt),##__VA_ARGS__)]
#define IMG(name)           [UIImage imageNamed:name]
#define COLOR(color)        [UIColor color]



#pragma mark - File  functions
#define PATH_OF_APP_HOME      NSHomeDirectory()
#define PATH_OF_TEMP          NSTemporaryDirectory()
#define PATH_OF_DOCUMENT      [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

你可能感兴趣的:(iOS 常用的宏)