zoukankan      html  css  js  c++  java
  • 常用宏定义

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

    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
  • 相关阅读:
    Windows 系统里面的 hosts 文件
    JDK 安装目录中 native2ascii.exe 命令详解
    火狐浏览器安装 Modify Headers 插件
    java iterator
    HashSet HashTable HashMap的区别
    c# 序列化
    Oracle 同步
    QL Server 高可用性(一)AlwaysOn 技术
    sqlserver 日志传送
    oracle forall
  • 原文地址:https://www.cnblogs.com/hushuai-ios/p/3679752.html
Copyright © 2011-2022 走看看