SUMMARY Objective-c features

Source: Internet
Author: User

Objective-C is obviously different from other object-oriented systems. It has its own distinctive characteristics. Next we will introduce its features from this method: compatibility, String, class, method, attribute, protocol, and classification.

1. Compatibility

Objective-C is an object-oriented C language. In objective-C code, there can be C and C ++ statements, which can call C functions, you can also use the C ++ object access method.

2. String

Objective-C generally does not use a C-language string. In most cases, it is a string of the nsstring type that uses the foundation framework. The nsstring class provides string class packaging and supports Unicode and printf-style formatting tools. It places a @ symbol before a regular double quotation mark string, as shown in the following example:

Nsstring * mystring = @ "my string \ n ";

Nsstring * anotherstring = [nsstring stringwithformat: @ "% d % s", 1, @ "string"];

3. Class

Objective-C is an object-oriented language, and defining a class is its basic capability. The class description and implementation of objective-C include the Interface part and the implementation part.

4. Method

Objective-C is an object-oriented language, and the definition method is also its basic capability. In objective-C, the method uses the [] operator instead of the "." operator. Sometimes a method call is also called message sending.

5. Attributes

Attribute is a concept proposed by objective-C 2.0. It is used to replace the "Getter" and "setter" methods for accessing member variables, to encapsulate a class, you can access the class through attributes instead of directly accessing the member variables.

6. Protocol

The protocol in objective-C is similar to the interface in Java or the pure virtual class in C ++. Only some of the interface definitions are not implemented, that is, only the H file does not have m files.

7. Category

In objective-C, categories are similar to inheritance mechanisms, and can be used to extend the features of parent classes.

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.