- // 安全释放
- #define RELEASE_SAFELY(__Pointer) do{[__Pointer release],__Pointer = nil;} while(0)
- // 屏幕的物理高度
- #define ScreenHeight [UIScreen mainScreen].bounds.size.height
- // 屏幕的物理宽度
- #define ScreenWidth [UIScreen mainScreen].bounds.size.width
- // 调试
- #define NSLOG_FUNCTION NSLog(@"%s,%d",__FUNCTION__,__LINE__)
- //----------------------图片————————————————————————————————————————
- //读取本地图片
- #define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
- //定义UIImage对象
- #define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]
- //定义UIImage对象
- #define ImageNamed(_pointer) [UIImage imageNamed:_pointer]
- //———————————————————————颜色类———————————————————————————-----—————————————
- // rgb颜色转换(16进制->10进制)
- #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
- //带有RGBA的颜色设置
- #define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
- // 获取RGB颜色
- #define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
- #define RGB(r,g,b) RGBA(r,g,b,1.0f)
- //背景色
- #define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]
- //清除背景色
- #define CLEARCOLOR [UIColor clearColor]
- #pragma mark - color functions
- #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
- #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
- //———————————————————————TAG宏———————————————————————————-----—————————————
- //viewWithTag
- #define VIEWWITHTAG(_OBJECT, _TAG) [_OBJECT viewWithTag : _TAG]
- //———————————————————————单例模式宏———————————————————————————-----—————————————
- //.h文件处的声明
- #define DEFINE_SINGLETON_FOR_HEADER(className) \
- \
- + (className *)shared##className;
- //.m文件处的声明
- #define DEFINE_SINGLETON_FOR_CLASS(className) \
- \
- + (className *)shared##className { \
- static className *shared##className = nil; \
- static dispatch_once_t onceToken; \
- dispatch_once(&onceToken, ^{ \
- shared##className = [[self alloc] init]; \
- }); \
- return shared##className; \
- }
- //———————————————————————单例模式———————————————————————————-----—————————————
- static DataBaseHandle * handle = nil;
- + (DataBaseHandle *)shareInstance
- {
- @synchronized(self){
- if (!handle) {
- handle = [[DataBaseHandle alloc] init];
- }
- }
- return handle;
- }
- —————————————不用你把所有NSLog的删除或注释,直接修改#if 判断的值就行了(1执行,0不执行)——————————————
- #if 1
- #define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
- #else
- #define NSLog(FORMAT, ...) nil
- #endif
- #define NEED_OUTPUT_LOG 0
- #if NEED_OUTPUT_LOG
- #define SLog(xx, ...) NSLog(xx, ##__VA_ARGS__)
- #define SLLog(xx, ...) NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- #define SLLogRect(rect) \
- SLLog(@"%s x=%f, y=%f, w=%f, h=%f", #rect, rect.origin.x, rect.origin.y, \
- rect.size.width, rect.size.height)
- #define SLLogPoint(pt) \
- SLLog(@"%s x=%f, y=%f", #pt, pt.x, pt.y)
- #define SLLogSize(size) \
- SLLog(@"%s w=%f, h=%f", #size, size.width, size.height)
- #define SLLogColor(_COLOR) \
- SLLog(@"%s h=%f, s=%f, v=%f", #_COLOR, _COLOR.hue, _COLOR.saturation, _COLOR.value)
- #define SLLogSuperViews(_VIEW) \
- { for (UIView* view = _VIEW; view; view = view.superview) { SLLog(@"%@", view); } }
- #define SLLogSubViews(_VIEW) \
- { for (UIView* view in [_VIEW subviews]) { SLLog(@"%@", view); } }
- #else
- #define SLog(xx, ...) ((void)0)
- #define SLLog(xx, ...) ((void)0)
- #endif
相关推荐
ESP32S3编译micropython固件
编译ESP32芯片的micropython固件
来,看看这20个常用的宏定义!
关注、星标公众号,直达精彩内容ID:技术让梦想更伟大作者:李肖遥写好C语言,漂亮的宏定义很重要,使用宏定义可以防止出错,提高可移植性,可读性,方便性等等。下面列举一些成熟软件中常用的宏定...
TypeScript版LangChain环境配置全攻略:从零搭建AI应用开发环境
大语言模型(LLM)作为当前AI应用开发的核心技术,通过API接口为开发者提供了强大的自然语言处理能力。其工作原理基于Transformer架构,通过预训练和微调实现对人类语言的深度理解与生成。在工程实践中,开发者需要将LLM与外部工具、数据源和业务逻辑有效集成,这正是LangChain框架的技术价值所在——它提供了标准化的组件和接口,简化了复杂AI应用的构建流程。应用场景涵盖智能客服、内容生成、数据分析助手等多个领域。本文聚焦于TypeScript/JavaScript生态下的LangChain开发,详细
IDA常见的宏定义(逆向)
/* This file contains definitions used by the Hex-Rays decompiler output. It has type definitions and convenience macros to make the output more readable. Copyright © 2007-2011 Hex-Rays */ #if defined...
使用DevExpress22.X(Patch)控件库在VisualStudio2022使用C#进行Winform、WPF应用的开发,看这一篇就够了!
写在开头,Dev Express是个十分强大的控件库(下文简称Dev),但碍于其高昂的使用费用,“出于学习目的”,我们一般使用的都是Patch版本(在版权意识日趋加强的当下,不要提那两个字,现在加上那些字,百度都搜不出内容)。
Wiley:International Journal for Numerical Methods in Biomedical Engineering投稿流程
中间过程省略,这个出版社很人性化,投稿的web UI也很好看。上传word之后,一步步跟着走就行,不用填太多东西。不要最后在最后检查阶段,重新上传word文件,这样会导致,之前针对word的操作全部改变。
C语言宏定义详解
C语言宏定义详解
最新版IAR9.40和注册工具
IAR最新版的IDE在编译速度和代码提示等各个方面上都有很大提升,软件这个东西果然还是越新越好。之前的时候,IAR v9系列网上很多人都说能用,但是又没有把 IAR v9系列的注册方法写的很清楚,导致我一直都用注册老版本v8的方法去注册v9。结果注册后都会提示。
IDA逆向常用宏定义
/* This file contains definitions used by the Hex-Rays decompiler output. It has type definitions and convenience macros to make the output more readable. Copyright (c) 2007-2011 Hex-Rays */ #if defined(__GNUC__) typedef long lon
大疆机场及无人机上云(航线规划、指令飞行...)
最近基于大疆上云api进行二次开发,后面将按照开发步骤对其进行说明!
优秀的 Verilog/FPGA开源项目介绍(十七)- AXI
优秀的 Verilog/FPGA开源项目介绍(十七)- AXI官网❝https://developer.arm.com/architectures/system-architectures...
IDA Pro plug-in defines
/* This file contains definitions used by the Hex-Rays decompiler output. It has type definitions and convenience macros to make the output more readable. Copyright (c) 2007-2011...
高频电磁场仿真-主题064-伴随变量法与灵敏度分析
在电磁器件优化设计中,梯度信息对于指导优化方向至关重要。考虑一个典型的电磁优化问题: 其中 p=[p1,p2,...,pn]Tp = [p_1, p_2, ..., p_n]^Tp=[p1,p2,...,pn]T 是设计参数向量(如几何尺寸、材料参数等)。传统有限差分法的困境:示例: 一个具有100个设计参数的天线优化问题伴随变量法(Adjoint Variable Method, AVM)通过引入伴随场,将梯度计算复杂度从 O(n)O(n)O(n) 降低到 O(1)O(1)O(1):伴随变量法在计算
iOS常用宏定义大全
iOS常用宏定义大全
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
Data-Structures-and-Algorithm-Analysis-in-Java.pdf
作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
iOS常用宏定义
为了简化开发流程,提升工作效率,收集了一些平时常用的宏定义,今后会不定期更新 1.UI元素 //NavBar高度 #define NAVIGATIONBAR_HEIGHT 44 //StatusBar高度 #define STATUSBAR_HEIGHT 20 //获取屏幕 宽度、高度 #define SCREEN_WIDTH ([UIScreen main...
Probability and Statistics - 4th edition
Probability and Statistics - 4th edition
C语言宏定义技巧(常用宏定义)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> C语言宏定义技巧(常用宏定义) <span id= "ob_logd35550">写好C语言,漂亮的宏定义很重要,使用宏定义可以防止出错,
jdk-8u144-linux-x64.tar.gz.
该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包
宏定义_20个成熟软件中常用的宏定义,赶快收藏!
写好C语言,漂亮的宏定义很重要,使用宏定义可以防止出错,提高可移植性,可读性,方便性等等。下面列举一些成熟软件中常用的宏定义。1. 防止一个头文件被重复包含1#ifndefCOMDEF_H2#defineCOMDEF_H3//头文件内容4#endif2. 重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类型字节数差异,方便移植。1typedefunsignedchar...
常用的宏定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
swift中常用宏定义
github学习地址:https://github.com/potato512/SYSwiftLearning // MARK: - 设备信息 /// 当前app信息 let GetAppInfo = NSBundle.mainBundle().infoDictionary /// 当前app版本号 let GetAppCurrentVersion = NSBundle.mai
常用宏定义总结
常用的宏定义总结 // // PrefixHeader.pch // JNdefine // // Created by Titan on 16/3/15. // Copyright © 2016年 Aaron Wong. All rights reserved. // #ifndef PrefixHeader_pch #define PrefixHea...
ios 常用宏定义大全
闲来无事, 根据以往项目经验,罗列一些最常用的宏定义,以供参考! 1. NSLog打印 #if DEBUG #define NSLog(FORMAT, ...) fprintf(stderr, "[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8St
C/C++常用宏定义
2019独角兽企业重金招聘Python工程师标准>>> ...
宏定义亲民级别,入门级别,常用方便宏定义
const double eps = 1e-8; //const只是用来定义常量,常量在代码中一直存在,但define是预处理功能,有本质区别 常用的浮点数比较宏定义: #define Equ(a,b) ((fabs((a)-(b)))<(eps)) //等于 #define More(a,b) (((a)-(b))>(esp)) //大于 #define Less(a,b) (((a...
IOS开发中常用的宏定义
有些时候,我们需要将代码简洁化,这样便于读代码。我们可以将一些不变的东东抽取出来,将变化的东西作为参数。定义为宏,这样在写的时候就简单多了。 下面例举了一些常用的宏定义和大家分享: 1. 判断设备的操作系统是不是ios7 #define IOS7 ( [[[UIDevice currentDevice].systemVersion doubleValue] >= 7.0] )
嵌入式工程师常用的宏定义
关注+星标公众号,不错过精彩内容编排 | 李肖遥来源 |技术让梦想更伟大写好C语言,漂亮的宏定义很重要,使用宏定义可以防止出错,提高可移植性,可读性,方便性等等。下面列举一些成熟软件中...
2560



被折叠的 条评论
为什么被折叠?



