"Smallfan iOS Learning Note 02" Basic syntax

Source: Internet
Author: User
Tags bitwise operators

This article comes from: Blog Park Codersmallfan. Reprint Please specify source: http://www.cnblogs.com/codersmallfan/p/3746837.html

Learning iOS students generally have a certain programming language foundation, so the basic grammar of this piece of things do not need to like "Tan xx called beast" kind of step by step, general also look at similarities and differences. Objective-c this language is derived from C, so the process-oriented thing is exactly the same as C, and the new object-oriented aspects of knowledge points, should be compared with C + +, This is also the only place that objective-c need to learn the basic grammar (the following refers to the syntax of C if forgotten, please review it yourself).

First, the basic data types are divided into int, float, double, char, and ID. The first 4 and C languages have long, short, unsigned, signed qualifier modifiers and support octal and hexadecimal formats. The int type and the C language are also device-dependent quantities, which are determined by the machine and can occupy 32 or 64 bits. It is important to note that in the NSLog string output function, placeholders for type int are more likely to use%i instead of%d (%li,%hi,%u). The last basic data type ID is a objective-c-specific type, which can be thought of as the void * type in C, which can store any type of object, and in a sense it is a generic object type.

Arithmetic expressions and unary operators are similar to the C language, modulo operator% is used only for integer processing, and type conversions are also classified as implicit conversions and explicit conversions (using parentheses and base types).

The loop structure (while, do, and for), the jump statement (break, continue), select the structure (if, else if, else, switch), the conditional operator (c? E1:E2), bitwise operators (with or non-, negation, shift), enum-type (enum) is the same as the C language. It is important to note that the right shift operation is actually the arithmetic right shift (by sign bit) or logical right shift (all 0) is also related to the system.

Objective-c, like the C + + language, supports Boolean variables.

// The "Yes" will be output int Ten ; if (isprime) {  NSLog (@ "Yes");          } Else {  NSLog (@ "No");  }
// The "Yes" will be output int 0 ; if (! iswrite) {  NSLog (@ "Yes");  } Else {  NSLog (@ "No");  }

Objective-c actually has a property with a bool type built in, with a predefined value of Yes and No.

about other related underlying grammatical features in objective-c, which will be mentioned in other chapters (e.g. static variables, global variables, etc.), there is no explanation.

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.