One, the OBJECTIVE-C runtime defines several important types.
Class: Defining the Objective-c Class
Ivar: Defines an instance variable of an object, including the type and name.
Protocol: Define formal agreements.
objc_property_t: Defines a property. This name may be called to prevent conflicts with user types in Objective-c 1.0, when there are no attributes.
Method: Defines an object method or class method. This type provides the name of the method (that is, the * * selector), the number and type of parameters, and the return value (which together is called the * * Signature of the method), and a function pointer to the code (that is, the method's implementation * *).
SEL: Defines the selector. The selector is a unique identifier for the method name.
-
IMP: Defines the method implementation. This is just a pointer to a function that takes an object, a selector, and a variable-length argument list (varargs), returning an object
Second, the difference between class_copypropertylist and Class_copyivarlist
Class_copypropertylist:
Gets the class's property variables through the class name.
Class_copyivarlist
Gets the instance variable of the class through the class name.
Other words:
Class_copypropertylist obtained is a variable modified by @property,
Class_copyivarlist obtained is class_copypropertylist modified and in the M file in the @implementation defined within the variable
eg
. h
@interface Model:nsobject
@property (nonatomic,copy) NSString *sex;
@property (nonatomic,copy) NSString *name;
@property (nonatomic,assign) Nsinteger age;
@property (Nonatomic,strong) nsdictionary *imgcode;
@end
. m
@interface Model ()
@property (nonatomic,copy) NSString *id;
@end
@implementation Model {
Nsinteger _index;
}
@end
When using the
unsigned int propertiescount = 0;
unsigned int ivarscount = 0;
objc_property_t *properties = class_copypropertylist (Model, &propertiescount);
Ivar *ivars = class_copyivarlist (Model, &ivarscount);
Then Propertiescount = 5
Ivarscount = 6
IOS Run-time mechanism