国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > iOS > 正文

iOS runtime 學(xué)習(xí)之類的屬性動(dòng)態(tài)獲取(一)

2019-11-08 00:21:54
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

蘋果官方文檔()如下: PRoperty Type String You can use the property_getAttributes function to discover the name, the @encode type string of a property, and other attributes of the property. The string starts with a T followed by the @encode type and a comma, and finishes with a V followed by the name of the backing instance variable. Between these, the attributes are specified by the following descriptors, separated by commas:

RThe property is read-only (readonly).(只讀屬性)CThe property is a copy of the value last assigned (copy).(復(fù)制屬性)&The property is a reference to the value last assigned (retain).(持有屬性)NThe property is non-atomic (nonatomic).(非原子性的,釋義為不是線程安全的。atomic是iOS使用的一種線程保護(hù)技術(shù),大意是一個(gè)進(jìn)程讀寫字段時(shí),防止數(shù)據(jù)錯(cuò)誤,另一個(gè)進(jìn)程不允許訪問(wèn)。而這種機(jī)制是耗費(fèi)系統(tǒng)資源的,所以如果沒(méi)有使用多線程間的通訊編程,那么nonatomic是一個(gè)非常好的選擇。)G<name>The property defines a custom getter selector name. The name follows the G (for example, GcustomGetter,).(用戶自定義的get方法名稱)S<name>The property defines a custom setter selector name. The name follows the S (for example, ScustomSetter:,).(用戶自定義的set方法名稱)DThe property is dynamic (@dynamic).(@dynamic告訴編譯器,屬性的setter與getter方法由用戶自己實(shí)現(xiàn),不自動(dòng)生成。)WThe property is a weak reference (__weak).(弱引用屬性)PThe property is eligible for garbage collection.(屬性的垃圾回收機(jī)制是合格的)t<encoding>Specifies the type using old-style encoding.(指定使用老式的編碼類型)

示例屬性:

@property char charDefault;Tc,VcharDefault@property double doubleDefault;Td,VdoubleDefault@property enum FooManChu enumDefault;Ti,VenumDefault@property float floatDefault;Tf,VfloatDefault@property int intDefault;Ti,VintDefault@property long longDefault;Tl,VlongDefault@property short shortDefault;Ts,VshortDefault@property signed signedDefault;Ti,VsignedDefault@property struct YorkshireTeaStruct structDefault;T{YorkshireTeaStruct="pot"i"lady"c},VstructDefault@property YorkshireTeaStructType typedefDefault;T{YorkshireTeaStruct="pot"i"lady"c},VtypedefDefault@property union MoneyUnion unionDefault;T(MoneyUnion="alone"f"down"d),VunionDefault@property unsigned unsignedDefault;TI,VunsignedDefault@property int (*functionPointerDefault)(char *);T^?,VfunctionPointerDefault@property id idDefault;Note: the compiler warns: "no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed"T@,VidDefault@property int *intPointer;T^i,VintPointer@property void *voidPointerDefault;T^v,VvoidPointerDefault@property int intSynthEquals;In the implementation block:@synthesize intSynthEquals=_intSynthEquals;Ti,V_intSynthEquals@property(getter=intGetFoo, setter=intSetFoo:) int intSetterGetter;Ti,GintGetFoo,SintSetFoo:,VintSetterGetter@property(readonly) int intReadonly;Ti,R,VintReadonly@property(getter=isIntReadOnlyGetter, readonly) int intReadonlyGetter;Ti,R,GisIntReadOnlyGetter@property(readwrite) int intReadwrite;Ti,VintReadwrite@property(assign) int intAssign;Ti,VintAssign@property(retain) id idRetain;T@,&,VidRetain@property(copy) id idCopy;T@,C,VidCopy@property(nonatomic) int intNonatomic;Ti,VintNonatomic@property(nonatomic, readonly, copy) id idReadonlyCopyNonatomic;T@,R,C,VidReadonlyCopyNonatomic@property(nonatomic, readonly, retain) id idReadonlyRetainNonatomic;T@,R,&,VidReadonlyRetainNonatomic

(附上鏈接https://developer.apple.com/library/prerelease/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101-SW1)


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 大连市| 克拉玛依市| 津市市| 商南县| 桦南县| 绥棱县| 涞源县| 通榆县| 东光县| 桑日县| 临猗县| 隆林| 昆山市| 镇康县| 清河县| 昌图县| 池州市| 新余市| 桃园市| 威海市| 津市市| 望城县| 如皋市| 卫辉市| 东光县| 静宁县| 广灵县| 旅游| 黔西县| 高青县| 松原市| 象山县| 黎平县| 哈尔滨市| 紫阳县| 汽车| 平舆县| 菏泽市| 屏东市| 西乌珠穆沁旗| 南乐县|