02-objective-c Annotations and identifiers

Source: Internet
Author: User

First, comments

1. What is a note?

A comment is a string that is used in the code to illustrate, not execute.

2. What is the definition of a note?

In OC, we use a double slash "//" to denote a single-line comment, with a double slash (//) at the very beginning of the code.

NSLog (@ "This line of code is a single-line comment");

We also use "/*" and "/*" to denote multiple lines of comment.

/*

NSLog (@ "The Moon Light before the window");

NSLog (@ "suspected ground frost");

NSLog (@ "Jutou looking at the moon");

NSLog (@ "head down to think of hometown");

*/

3. What is the role of annotations?

Note, it is mainly used to describe the role of a piece of code, it can also be used to describe a class, the role of a method, and it can also be the parameters of the method and the return value of the data type of information such as description.

Annotations can also be a good way to debug a program. For example, if you suspect that a piece of code might have a problem, then we can annotate the code, and if it does not work correctly, then we can determine that there is a problem in the code. This allows you to adjust the scope of the investigation. On the other hand, if you still get an error, then you can be sure that this code is not a problem, and you can troubleshoot the usability of the code.

4. Note:

Multi-line annotations cannot be nested.

Second, the variable

1. What are the variables?

When we are programming data, we can imagine that "variables" are like a container that "dresses up" the data we need to process.

2. Use of variables?

Use the identifier as the name of the variable, and then we can assign the data to the variable.

int age = 25; Age is a variable and assigns a value of 25 to it.

Second, identifiers

1. What is an identifier?

is the symbol that gives the variable, class, method a name.

2. What are the rules for writing identifiers?

① identifiers can consist of letters, numbers, underscores, and dollar characters, but they cannot start with a number.

② cannot be the OC keyword.

③ cannot contain null characters.

④ can contain only dollar symbols and cannot contain other special characters.

02-objective-c Annotations and identifiers

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.