This article comes from: Blog Park Codersmallfan. Reprint Please specify source: http://www.cnblogs.com/codersmallfan/p/3746329.html
Like other platform development, learning iOS development should also have a language and an operating system as a platform, the language is objective C, and this operating system for Mac OSX. If the students who have a slight pass in English should be able to see some doorway from the word objective, the Chinese meaning of object [Count], objective direct meaning as the goal, here is actually object-oriented meaning, in fact, is an expansion of the C object-oriented programming language, The concept of such things as a small rookie I do not understand, fortunately we have objective-c guidelines. Mac OSX is Apple's operating system, which is a different operating system from the Windows family, which needs to be tried before iOS development (it doesn't have to be professional, but at least it will be used) and is also transmitted.
Learning iOS development requires at least the following conditions:
-
- One Mac computer (MacBook Air, MacBook pro[recommended), Mac Mini, IMac, Mac Pro all available
- OSX OS (some nonsense)
- Compiling the integrated environment Xcode (recommended 5.0 or later, can also use bash+ text editing)
Make sure you have the above conditions and you can start learning.
Because OSX is based on the Unix kernel, the UNIX command set is used. The UNIX command set is a fairly powerful and huge tool, but it seems that we need to master just a few commands in the early stages. First we try to create a source file from the terminal (Terminal). The steps to open terminal are as follows: finder→ application → utilities → terminal. (for example, the default is black on white, you can modify the color mode)
Common commands are: mkdir, touch, open, CD, Ls-l, Cc-c, CC.
- mkdir to create a folder, usage: mkdir Prog //Create a folder named Prog
- Touch to create a file, usage: Touch MYFIRSTCODE.M //Create a file named MYFIRSTCODE.M (objective C's source file suffix is. m, different from C. C or C + +. cpp)
- Open for opening an existing file, usage: Open MYFIRSTCODE.M //opening MYFIRSTCODE.M file (if Xcode is installed, it will be opened by default)
- CD for access to a certain level of directory, usage: CD Prog //Locate the directory in the Prog folder
- Ls-l to browse all files in the current directory, usage: ls-l
- Cc-c for compiling instructions, usage: cc-c myfirstcode.m //compiling MYFIRSTCODE.M file, generating target file MYFIRSTCODE.O
- CC for link instruction, usage: CC MYFIRSTCODE.O -framework Foundation //link MYFIRSTCODE.O target file (the file uses the foundation, So you need to include the-framework frame parameter) to generate the A.out file
After opening, as right, it is the Xcode editing interface.
Next, according to international practice, we will write the Hello World program.
The code is as follows:
1 #import<Foundation/Foundation.h>2 3 intMainintARGC,Const Char*argv[])4 {5 @autoreleasepool {6NSLog (@"Hello world!");7 } 8}
Compile the link execution process and the results are as follows:
See no, Hello world! Our first program is finished, of course, here for the time not to explain the grammar, I believe that the C-language basis of the students can understand, as to what @autoreleasepool is a temporary regardless, nslog similar to printf. Here's how to use Xcode to build a project and compile a link to run it completely.
Open the finder→ application →xcode.app
Click the Create a Xcode project button to build a new project.
Select the application option in OS X and in the right window Select command line tool to create the console program.
Type Select your library types, OBJECTIVE-C Select the foundation framework, c select C,c++ Select C + +, and so on.
Click the main.m file in the left column to start editing the code, edit and press the top left corner to compile → link → run. The results are as follows:
Hey? Where is the result of the operation? Take a closer look, isn't it in the lower right form, Hello world, see?