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 ~~
.