Objective-C basic data types, expressions, and statements, type expressions
I. Basic Data Type
1. When defining variables in a general computer language, you must provide two types and names.
For example, int myClassID;
2. in Xcode, whether you are using the GCC compiler or LLVM compiler, if we do not initialize the value of the integer variable, during the compilation process, the compiler automatically attaches a value of 0 to it.
3. Integer type: three types. Int, short, and long.
Floating Point Number Type: float and double.
Character Type: char.
Pointer type :*. The so-called pointer variable clearly points to a content address.
Struct: struct.
II. Naming rules
1. There is no anonymous name in the world of computers. Even if the "ghost" compiler caused by developers' negligence will always include a special name for it during compilation.
2. Name Error
3. Naming rules:
A. In C language, the Hungarian naming method is widely used by developers. Rule: variable name = variable property + variable type + description.
B. Attribute access feature of OC: class member variables are generally named as _ + description.
C. In the description section of a variable name, we generally use the hump naming method, that is, the first letter of each word is capitalized, but the first name of the variable name in OC generally needs to be lowercase.
For example, NSString * strUnitTestResult;
NSString * unitTestResult;
However, the hump naming method that distinguishes words with underscores is rarely used in OC. For example, NSString * unit_Test_Result;
4. namespace
B. In C ++, The namespace mechanism is used to distinguish the same name. In this way, we can name a local project as a group, name the libraries of other teams as a group, and name a third-party library as a group. When an element is called, we not only need to provide the element name, but also the group where the element is located.
C. For C and OC, The namespace mechanism is not used. However, you can add different prefixes to the names of elements to achieve the namespace function.
For example, when defining some globally visible variables, the uniqueness is often indicated by a "prefix.
For example:
Enum {
KTestDomainErrParam,
KTestDomainErrPipe,
KTestDomainErrFile,
};
The variable in the enumerator defines the prefix of kTestDomain.
3. Expression
1. Arithmetic Operators
2. Comparison Operators
3. logical operators
4. bitwise operators
4. Statement