(Ios development study note 7) Composition of objective C basic classes

Source: Internet
Author: User

Frontier:

A Brief Introduction to the composition of Objective C classes includes the methods of attributes, variables, methods, and multiple parameters.

 

Step One select and create a class

Step Two create an H file

Notes:

 1 + and-

+ Static method (class method)-object method (called only after an instance is required)

 2The variables in interface {} are private variables of the class, and the External table cannot be called.

3 @ property indicates the property

Description of common parameters

Nonatomic: Non-atomic, thread unsafe

Atomic: atomic

Readwrite: read/write

Readonly: Read-Only

Copy is used to create and allocate a new space and copy the content from the original address.

Assign is just a simple pointer transfer.

Retain is after passing the pointer retainCount + 1

 

4 multi-parameter method implementation

The multi-parameter method implementation in other languages is generally the void method name (Data Format parameter 1, data format parameter 2 );

Multi-parameter methods in objective C are implemented

The advantage of this method is that it is helpful for reading

 

Step Three create m file

Note:

@ Synthesize carno = _ carno; implement attributes and create the SetCarno set method at the same time (if the set method is not implemented, attributes cannot be set)

 

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.