Manual reference Counting in rules

Source: Internet
Author: User

Implementation of the Assign, retain, and copy three attributes when assigning a value to a property using the Set Value method

Self.property = newvalue;

The Assign feature would be this:

property = NewValue;

The retain feature would be like this

if (property!=0) {

[Property release];

property = [NewValue retain];

}

The feature of copy is this

if (property!=0) {

[Property release];

property = [newvalue copy];

}

If you want to keep an object from being destroyed you can use retain, and release is required after you have finished using the object.

Releasing a message to an object does not release the object, but is not destroyed until the object's reference count is 0. The system then sends a DEALLOC message to the object to free up memory.

There is no need to use an object in the method, but this object does have a return value that can send a autorelease message to this object to mark the object's deferred release, Autorelease does not affect the object's reference count.

Manual reference Counting in rules

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.