1. 格式化輸出:NSLog(@"");
%@ ? ? 對象
%d, %i 整數(shù)
%u ? ? 無符整形
%f ? ? 浮點(diǎn)/雙字
%x, %X 二進(jìn)制整數(shù)
%o ? ? 八進(jìn)制整數(shù)
%zu ? ?size_t
%p ? ? 指針
%e ? ? 浮點(diǎn)/雙字 (科學(xué)計算)
%g ? ? 浮點(diǎn)/雙字
%s ? ? C 字符串
%.*s ? Pascal字符串
%c ? ? 字符
%C ? ? unichar
%lld ? 64位長整數(shù)(long long)
%llu ? 無符64位長整數(shù)
%Lf ? ?64位雙字
%e 是實(shí)數(shù),用科學(xué)計數(shù)法計的
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? ? ? ? ? ? ? ? ? ?| 復(fù)制
? &? ? | strong/retain? ? ? ?| 強(qiáng)引用
? W? ?| weak? ? ? ? ? ????????| 弱引用
Sxxx: | setter? ? ? ? ????????| set方法
?Gxxx | getter? ? ? ? ? ? ? ?| get方法
?Vxxx | var? ? ? ? ? ? ? ? ? ?| 實(shí)例變量