• 常用宏定义


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

    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
  • 相关阅读:
    url末尾的斜杠作用
    awk 工具可以很灵活地对文本进行处理,这里的 awk '{print $2}'是指第二列的内容,是运行的程序 ID。 杀死指定进程
    nil和空切片
    WaitGroup源码设计,
    2
    t
    Go内置的定时器
    分布式定时器
    1 2 交换
    order by 1 DESC 2 desc
  • 原文地址:https://www.cnblogs.com/hushuai-ios/p/3679752.html
Copyright © 2020-2023  润新知