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
  • 相关阅读:
    降龙十八掌之三:(见龙在田)优化查询性能
    完整的项目工程目录结构
    降龙十八掌之一:(亢龙有悔)SQL Server Profiler和数据库引擎优化顾问
    ASP.NET状态管理的总结
    LINQ 图解
    获取IP城市
    Eclipse 编译StanfordNLP
    Centos JAVA Eclipse
    关掉PUTTY后,进程仍可以运行。
    centos lnmp 安装笔记
  • 原文地址:https://www.cnblogs.com/hushuai-ios/p/3679752.html
Copyright © 2011-2022 走看看