OBJECTIVE-C basic data types, expressions, and statements

Source: Internet
Author: User
Tags access properties bitwise operators

One. Basic data types

1. General computer language when defining variables, you need to provide two content: type and name.

For example: int myclassid;

2. In Xcode, whether you are using the GCC compiler or the LLVM compiler, if we do not initialize the value of an integer variable, the compiler automatically attaches a value of 0 to it during compilation.

3. Integer type: three kinds. int, short, long.

Floating-point types: Two: float, double.

Character type: one: Char.

Pointer type: *. The so-called pointer variable explicitly points to a content address.

struct: struct.

Two. Naming rules

1. There is no anonymous in the world of computers, even those "ghost ghosts" compilers that are inadvertently created by developers are bound to attach special names to them when compiling.

2. Naming errors

3. Naming conventions:

A. In the C language, the "Hungarian nomenclature" is widely loved by developers. Rule: Variable name = variable attribute + variable type + description.

B. Attribute access properties for OC: Class member variables are typically named: _+ description.

C. In the "description" section of the variable name, we generally use the camel-named method, which is the first letter of each word capitalized, but the first digit of the variable name in OC generally needs lowercase.

For example: NSString *strunittestresult;

NSString *unittestresult;

The hump naming method, which uses underscores to differentiate words, is used relatively infrequently in OC. such as: NSString *unit_test_result;

4. Namespaces

B. In the C + + language, the namespace mechanism is used to differentiate the same naming. In this way, we can name the local project as a group, name the other team's library as a group, name the third-party library as a group, and when we call an element, we need to provide not only the name of the element, but also the group that contains the element.

C. For C and OC, the mechanism of namespace is not adopted, but we can add different prefixes to the names when the elements are named, and we can achieve the function of namespace.

For example, when defining some globally visible variables in the definition, the "prefix" is often the way to indicate uniqueness.

Like:

enum{
Ktestdomainerrparam,
Ktestdomainerrpipe,
Ktestdomainerrfile,
};

The variable in the enumerator defines the prefix that is ktestdomain for it.

Three. An expression

1. Arithmetic operators

2. Comparison operators

3. Logical operators

4. Bitwise operators

Four. Statement

OBJECTIVE-C basic data types, expressions, and statements

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.