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.