Absrtact: Objective-c introduces the concept of " instance variable" , but at the same time, the sound of "member variable" is often seen. What is the difference between an instance variable and a member variable?
when viewing Apple's official documentation today (see below). Https://developer.apple.com/library/mac/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer /index.html
A new noun was found: the member variable (member variable). It is novel because it is called an instance variable (instance variable). Remember, when first contact objective-c, see instance variable this noun, feel very novel. We also try to compare the instance variables with the member variables and study their differences. From this diagram below, it can be concluded that the instance variables I saw earlier, essentially, are member variables. For iOS beginners, a novel noun can easily make people think too much.
MyClass *math=[[myclass alloc] init];in the figure "Member Variable declarations", literally means: "Member variable Declaration". It appears that the variable declared in {} is a member variable. So what does an instance variable mean? since OC is expressed in English, it may be useful to look up the original meaning in English. classes: Class (Description/template for a object)
Example: Instance (Manifestation of a Class)
MSG: Message (Sent to object to make it Act)
Methods: Method (code invoked by a Message)
instance variable: Instance Variable (object-specific storage) member variable (member Varialbe)Superclass/Sub-class: Superclass/subclass (Inheritance)
Protocol: Protocol (non-class-specific methods) from the English explanation given, it can be seen that the instance (Instance) is for class. An instance is a declaration of a class, whereby an instance variable (Instance Variable) refers to an object declared by a class. strictly speaking, int count in, is a member variable. and NSString * name; is an instance variable, and math is an instance variable.
should ID data belong to a member variable or an instance variable? Because the ID is an OC-specific type. In essence, the ID is equivalent to (void *). so ID data should belong to the instance variable.
OC instance variable (Instance var) and member variable (member Var) difference