1. 格式化输出:NSLog(@"");
%@ 对象
%d, %i 整数
%u 无符整形
%f 浮点/双字
%x, %X 二进制整数
%o 八进制整数
%zu size_t
%p 指针
%e 浮点/双字 (科学计算)
%g 浮点/双字
%s C 字符串
%.*s Pascal字符串
%c 字符
%C unichar
%lld 64位长整数(long long)
%llu 无符64位长整数
%Lf 64位双字
%e 是实数,用科学计数法计的
2. 类属性的 attribute
/// Defines a property attribute
typedef struct {
const char * _Nonnull name; /**< The name of the attribute */
const char * _Nonnull value; /**< The value of the attribute (usually empty) */
} objc_property_attribute_t;
unsigned int outCount = 0;
objc_property_t *propertyList = class_copyPropertyList([UIView class], &outCount);
for (int i = 0; i < outCount; i++) {
const char *name = property_getName(propertyList[i]);
const char *attribute = property_getAttributes(propertyList[i]);
NSLog(@"\nname = %s\nattribute = %s\n", name, attribute);
}
name = _mapkit_doubleFrame
attribute = T{CGRect={CGPoint=dd}{CGSize=dd}},R,N
name = monitorsSubtree
attribute = TB,N,G_monitorsSubtree,S_setMonitorsSubtree:
字母 | OC | 含义
------ |--------------- |---
有R | readonly | 只读
无R | readwrite | 读写
有N | nonatomic | 线程不安全
无N | atomic | 线程安全
C | copy | 复制
& | strong/retain | 强引用
W | weak | 弱引用
Sxxx: | setter | set方法
Gxxx | getter | get方法
Vxxx | var | 实例变量
网友评论