iOS Foundation--alloc, Init, and new methods

Source: Internet
Author: User

Alloc: Allocates memory.

Init: Initialize.

NEW: Instead of the above two functions: Allocate memory and initialize.

Attention:

1. New is seldom used in real-world development, and we generally create objects when we are

[[ClassName Alloc]init];

2. The difference is that Alloc allocates memory when the zone is used when allocating memory to an object, the associated object is allocated to an adjacent area of memory so that it consumes very little memory at the time of the call and increases the processing speed of the program.

3. Deprecated NEW: The reason is that using new, the initialization method is fixed to use init only, and cannot invoke other INITXX methods.

4. The new method can only be initialized with the default Init method, and other custom initialization methods may be used in a alloc manner.

iOS Foundation--alloc, Init, and new 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.