Getter and Setter methods

Source: Internet
Author: User

Setter method under Arc

-(void) Setuserarray: (Nsarray *) Userarray
{
_userarray = Userarray;
}

Getter method

-(Nsarray *) Userarray
{
return _userarray;
}

Setter under the MRC

-(void) Setuserarray: (Nsarray *) Userarray
{
if (_userarray! = Userarray) {

[_userarray release];

_userarray = [Userarray retain];
}
}

Getter method

-(Nsarray *) Userarray
{
return _userarray;
}

Getter Method MRC ARC is the same

If the getter and setter are all rewritten, you need to add

when you need to override the setter and getter methods, you need to with @sythesize abc = _ABC;

When overriding one, you do not need to use

you can see that in the interface @interface parentheses are collectively referred to as "member variables", the instance variable is one of the member variables!

the English translation of the instance variable is Instance Variable (object-specific storage)

An example of the English translation of Instance(manifestation of a class ) is said to be "the performance of the classes", stating that the instance variables should be Variables defined by the class!

remove basic data type int float .... And so on, other types of variables are called instance variables. That is, instance variables (with setter and getter) + Basic data type variables (int, float, and so on) = member variable

* * Instance variable + basic data type variable = member Variable * *

Getter and Setter methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.