IOS basics-alloc, init, and new methods, iosallocinitnew

Source: Internet
Author: User

IOS basics-alloc, init, and new methods, iosallocinitnew

Alloc: memory allocation.

Init: initialization.

New: instead of the above two functions: allocate memory and initialize.

 

Note:

1. In actual development, new is rarely used. Generally, when an object is created

[[ClassName alloc] init];

2. the difference is that when alloc allocates memory, zone is used to allocate memory to objects and the associated objects are allocated to an adjacent memory area, in this way, a small amount of memory is consumed during the call, improving the processing speed of the program.

3. new is not recommended. If new is used, the initialization method is fixed and only init can be used. Other initXX methods cannot be called.

4. Only the default init method can be used to complete initialization using the new method. Other customized initialization methods can be used using alloc.

 

Related Article

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.