After learning objective-C for a week, I read the classic "Learn objective-C on the Mac". Learn and remember, and send Study Notes to your blog for reference anytime, anywhere.
Write iPhoneProgramOr the Mac OS X software mainly uses xcode on the Mac platform. Although C # Mono is also useful, it is not ideal after all.
We do not recommend using virtual machines on a PC.Special MeansInstall the Mac on the PC. Refer to the tutorials in the snow leopard section of bbs.pcbeta.com and download and install the latest version of xcode on the Apple website.
For students who have blurred C, it is recommended to quickly review the syntax, pointer, and struct of C.
Run xcode to create the project command line tool --> Foundation (type)
Helloworld. mCodeAs follows:
# Import <Foundation/Foundation. h> int main (INT argc, const char * argv []) {nslog (@ "Hello, objective-C! "); Return 0;} // main
Output result:
02:55:28. 232 1. helloworld [685: 80f] Hello, objective-C!
The nslog () function is similar to printf (), but nslog () adds timestamp, date stamp, and automatically append Line Break ('\ n.
Cocoa adds the "ns" prefix to all functions, constants, and type names. This prefix tells you that the function comes from cocoa rather than other toolkit. The prefix of "ns" comes from "nextstep ".
The character "@" indicates that the referenced string should be processed as the nsstring element of cocoa.
Now you can set xcode: Select xcode | prefrences on the top menu bar, set indentation (I prefer the 8-digit Tab character), font color, and so on.
Boolean Type (bool)
Bool has yes and no values. Bool is actually a definition of signed Char (typedef). It uses an 8-bit bucket, and yes is defined as 1, no is defined as 0 (use # define ).