QFord:
First , I would like to introduce you a good tutorial : Learn Objective C on Mac .
All materials I wrote here base on this book !(QFord@QQ.COM)
I : Hello, the world !
1:Xcode uses the .m extension to indicate a file that holds Objective- C code
2: #import <Foundation/Foundation.h>
Objective- C uses header files to hold the declarations of elements such as
structs, symbolic constants, and function prototypes.
The #import <Foundation/Foundation.h> statement tells the compiler to look at the
Foundation.h header file in the Foundation framework.
3:NSLog just like printf in c ,but it supports ouput NSString.
As you can see here , at sigh before a string ,it indicates a NSString .
II :BOOL type
1:The areIntsDifferent() function
It takes two integer parameters and returns a BOOL value. The syntax should be familiar to you from your C experience.
Objc has 2 BOOL value : YES & NO
2:The boolString() function
It maps a numeric BOOL value to a string that’s readable by mere humans
Notice that the return type of boolString() is a pointer to an NSString.
3:The main() function
You can see that the two fives will replace the two %d format placeholders in our call to NSLog().
At the end of the string we’re giving to NSLog(), you see another at sign. This time, it’s %@.
What’s that all about? boolString() returns an NSString pointer. printf() has no idea
how to work with an NSString, so there is no a format specifier we can use. The makers of
NSLog() added the %@ format specifier to instruct NSLog() to take the appropriate argu-
ment, treat it as an NSString, use the characters from that string, and send it out to the
console.