常用宏定义

//----时间字符串转时间戳---

format 示例  @"yyyy-MM-dd HH:mm:ss"

#define TIMESTR_TO_C(dateStr,format)\

NSDateFormatter* formatter = [[NSDateFormatter alloc] init];\

[formatter setDateFormat:format];\

NSDate *dateP = [formatter dateFromString:dateStr];\

dateStr = [NSString stringWithFormat:@"%ld", (long)[dateP timeIntervalSince1970]]

//----时间戳转字符串----

#define TIMEC_TO_STR(dateStr,format)\

NSDateFormatter* formatter = [[NSDateFormatter alloc] init];\

[formatter setDateFormat:format];\

NSDate *date = [NSDate dateWithTimeIntervalSince1970:dateStr.longLongValue];\

dateStr = [formatter stringFromDate:date]

//获取设备信息

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



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



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

//UTF8转码

#define UTF8(string) [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

//视图顶部高度

#define DeviceTop  (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)?20:0)

//加载时判断项目类型

#ifdef __OBJC__  

    #import <UIKit/UIKit.h>  

    #import <Foundation/Foundation.h>  

#import "AppDelegate.h"  

#endif 

//操作系统版本限制

#ifndef __IPHONE_3_0

#warning "This project uses features only available in iOS SDK 3.0 and later."

#endif

 

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