美文网首页
iOS开发中的常用define定义

iOS开发中的常用define定义

作者: 优雅的步伐 | 来源:发表于2018-10-12 15:48 被阅读0次

iOS开发中的常用define定义

//获取iphone的基本信息:

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

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

#define IOS7_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)

#define IOS8_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=8.0)

#define IOS9_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=9.0)

#define IOS_VERSION_10 (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_9_x_Max)?(YES):(NO)

#define DeviceId [UIDevice currentDevice].identifierForVendor.UUIDString

// weakself 宏

#define WEAKSELF    __weak __typeof(&*self) weakSelf = self;

//接口定义

#define HTTP_ORDER_LIST   @"order/list"

//block相关宏

#define VDBlockSafeRun(block, ...) block ? block(__VA_ARGS__) : nil

//测试时使用log打印信息,发布时删除打印

#ifndef __OPTIMIZE__//DEBUG

# define NSLog(...) NSLog(__VA_ARGS__)

#else

# define NSLog(...)

#endif

注:

#ifdef是条件编译语句,在编译阶段执行,后面跟一个宏的名称,如果这个宏已经定义了,就编译对应的语句

#ifndef是条件编译语句,在编译阶段执行,后面跟一个宏的名称,如果这个宏没有定义,就编译对应的语句

相关文章

  • iOS开发中的常用define定义

    iOS开发中的常用define定义 //获取iphone的基本信息: #define ScreenHeight [...

  • iOS常用宏 定义

    iOS开发过程中,使用的一些常用宏定义 字符串是否为空#define kStringIsEmpty(str) ([...

  • iOS开发中你真的会用#define么!!!?

    iOS开发中你真的会用#define么!!!? iOS开发中你真的会用#define么!!!?

  • define与const

    在开发中我们经常用到define和const,那么他们怎么使用,区别在哪里: define: 宏定义,他只是在编译...

  • iOS常用宏定义

    整理 //常用宏定义 //是否为V以上系统 #define IOS(V) [[[UIDevice currentD...

  • 取色值相关宏

    iOS中,常用的获取RGB颜色值和十六进制颜色值转换方法的宏定义。#define RGB(r,g,b) ...

  • iOS 开发小经验

    iOS 开发中你是否遇到这些经验问题(一)iOS 开发中你是否遇到这些经验问题(二)iOS 日常工作之常用宏定义大全

  • iOS中宏(#define)与常量(const)的使用

    iOS开发中经常用到#define进行文本替换,const修饰数据类型。下面说一下他们的使用细节。 #define...

  • 内联函数与宏定义

    内联函数与宏定义 在C中,常用预处理语句#define来代替一个函数定义。例如:#define MAX(a,b) ...

  • iOS-使用strong,copy,assign,weak 修饰

    目录 assignweakstrongcopy 序言 在iOS开发中定义@property属性时,经常用到assi...

网友评论

      本文标题:iOS开发中的常用define定义

      本文链接:https://www.haomeiwen.com/subject/islgaftx.html