[Object-C language Essay 2] print debugging statements and Automatic Layout commonly used in nslog

Source: Internet
Author: User

 

Li huaming himiOriginal, reprinted must be explicitly noted:
Reprinted from[Heimi gamedev block]Link: http://www.himigame.com/iphone-object/395.html

 

 

Although the C language has been in touch for a long time, and I have used C ++ to write a PC single-host game, but I have not been in touch with it for a long time. I can't help it ~ Haha;

This section briefly describes the common statements for debugging and printing in object-C:

Simple types are defined as follows:

// Definitions of common types <br/> int I = 10; <br/> bool isshow = yes; <br/> // bool isshow = 1; <br/> float F = 3.1415926; <br/> char a = 120; <br/> nsstring * name = @ "himi ";

The above code has two basic types:

The first is a Boolean value, which is declared in object-C using bool;

Second: nsstring is used for string definition. We all know that the string is of the class type. Obviously, when the C language declares its object in this type of object, * pointer is used, I am not very familiar with the pointer concept. Please refer to "du Niang ~

Then print the statement using the [nslog (@ "")] statement, as follows:

// Common print statement <br/> nslog (@ "string: % @", name); <br/> nslog (@ "character: % C", ); <br/> nslog (@ "Boolean value: % I", isshow); <br/> nslog (@ "INTEGER: % I", I ); <br/> nslog (@ "Single-precision floating point: % F", f); <br/> nslog (@ "precise floating point number, with only two decimal places: %. 2f ", f); <br/> nslog (@" scientific and technical method: % E ", F ); <br/> nslog (@ "scientific and technological method (in the simplest way): % G", f); <br/> nslog (@ "Print two integers at the same time: I = % I, F = % F ", I, F ); 

The print method is % +? In the preceding two types of code, we can see that in objectc, string constants are character sequences enclosed by the @ symbol and a pair of "" Double quotation marks, print strings using % @;

 

All code:

# Import <Foundation/Foundation. h> <br/> int main (INT argc, const char * argv []) {<br/> // set the automatic release pool <br/> NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init]; <br/> // definition of common types <br/> int I = 10; <br/> bool isshow = true; <br/> float F = 3.1415926; <br/> char a = 120; <br/> nsstring * name = @ "himi "; <br/> // common print statement <br/> nslog (@ "string: % @", name); <br/> nslog (@ "character: % C ", a); <br/> nslog (@ "Boolean value: % I", isshow); <br/> nslog (@ "INTEGER: % I", I ); <br/> nslog (@ "Single-precision floating point: % F", f); <br/> nslog (@ "precise floating point number, with only two decimal places: %. 2f ", f); <br/> nslog (@" scientific and technical method: % E ", F ); <br/> nslog (@ "scientific and technological method (in the simplest way): % G", f); <br/> nslog (@ "Print two integers at the same time: I = % I, F = % F ", I, f); <br/> [pool drain]; <br/> return 0; <br/>}< br/>

 

After studying xcode, we found that in edit-format-Re indent, the code is re-typed ~~

 

.


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.