Today, smartphones are becoming increasingly popular, especially Apple's iPhone and Google's Android systems. Here I will introduce you to the basics of iPhone development. To make it easier for people who are new to learning to get started as soon as possible, I try to describe it with code.
For iPhone development, Mac and iPhone are indispensable. Although some people can install mac on a PC and use "black apple", it is not orthodox after all, this problem often occurs, for example, wireless or sound card problems, so Mac may need it. For iPhone, although it can view the program execution effect on the computer through the simulator, however, some features can only be executed on a real machine, so the iPhone is also essential. I am using the MacBook Pro 990 and iPhone generation. Now we should use iPhone 3G or 3gs.
Well, the first lesson of program development starts with the classic Hello world, and I cannot avoid it. This lesson will print the hello World string on the iPhone. The steps are as follows:
1. Download the iPhone SDK at http://developer.apple.com/, as shown in the following figure:
2. The iPhone SDK includes the development tools provided by Apple: xcode, interface builder, and instrument. They are completely free of charge and can be downloaded after successful attention and account activation, this SDK has a very large capacity of about GB, so it takes a very long time to download it.
3. After the download is complete, the installation process is very easy. You can simply double-click the downloaded DMG file to install the tool. The installation process may take about 10 minutes.
4. Find xcode In the developer/Application folder after installation. double-click the app and execute it. This is the development tool provided by Apple for Mac and iPhone development. You 'd better put it on the dock.
5. After xcode is started, create an iPhone OS project named helloworld. Select application under iPhone OS on the left and select View-based application on the right, for example, if you see the following, click choosebutton. Then, xcode prompts you to enter the project name and enter helloworld directly:
6. In the new project, click build and runbutton to compile and execute the program. The program execution result is shown as follows:
7. We can see that the program runs smoothly and the iPhone simulator is displayed. There is an empty interface in it. After all, we have nothing to write.
8. Now I want to display the hello World string on the interface. I need to write some code. iPhone and Mac development mainly use objective-C language, which is a superset of C language, readers familiar with C ++ and Java should be able to get started very quickly. It is just a bit different from objective-C's syntax. Just take some time to adapt.
9. Open helloworldviewcontroller. the M file is written in the viewdidload function, for example, the following code (note: this function is staring by default, and you need to cancel the gaze before writing the Code ), the complete function implementation is shown as follows:
10. Click build and runbutton again to execute the program. The result displayed by the simulator is as shown in the following figure. The Hello World string is displayed successfully!
In this section, I did not introduce the details involved in iPhone development. I just introduced the iPhone development process through a simple example. The purpose is to help you get started as soon as possible and cultivate confidence, next we will go deep into the detailed process of iPhone development. For the next lesson, see :-)
Graphic tutorial for iPhone Development