Getting started with IOS environment construction and development
1. register an Apple ID
1. Download iTunes from the apple website.
Http://www.apple.com/itunes/download/
2. Install iTunes.
3. Start iTunes and select iTunes store in the navigation bar
4. Pull the display page to the bottom and choose manage> change country or region.
5. Switch to the US (United States)
6. Select free apps (free software)
Click free app
Then, a dialog box is displayed, and click "create new account ".
Double-click to select Continue
Fill in the registration information and related questions, and select continue.
7. If you do not have a US credit card, you only need to select "NONE ".
8. When entering the US address, note that do not fill in the US address unless entered. Otherwise, it is easy to be called back. The following duty-free addresses are available:
(Fill in Fairbanks for the address and city when registering, and select Ak-Alaska for the State [on the top], [zipcode] Zip code 99701, Tel. 907-6284234)
9. After all the information is confirmed, you need to go to the mailbox to receive a confirmation activation email. After confirmation, the formal application is successful.
2. Register a developer account
1. Enter Website: http://developer.apple.com/programs/ios/
2. Select Enroll now.
3. Select continue.
4. If you have not registered an Apple ID before, you can select the first item and register an Apple id. Here, select the second item to use an existing Apple id for registration.
5. Register as an individual.
6. log on to the Apple id.
7. Fill in your personal information. Note that the name must be the English name (pinyin) on your credit card ).
8. Select IOS Developer Program.
9. Confirm your personal information.
10. Agree to iOS Developer Program License Agreement and select I agree
11. Print the application form, enter the information, sign the signature, and fax it to Apple. Wait for an email from Apple and activate the application.
3. Prepare the hardware environment
1. prepare a Mac Book containing mac_ OS _x. It must be an Intel-based Macintosh computer (if it is not an apple machine, see the appendix for MAC system installation). The operating system version should be later than 10.6.2, because the minimum operating system version required for iOS sdk4 and later versions is 10.6.2.
2. iPhone or iPod Touch, mainly used to test compiled programs
4. Download and install ios sdk and development tool X-CODE
1. Enter the URL: http://archive.cnblogs.com/a/2005710/
The web page provides various versions of the SDK and X-CODE official.
Select a suitable version for download.
2. Install iphonesdk:
Find the Installation File of iphonesdk on Mac, and double-click the file icon. A pop-up window is displayed:
Select to continue and wait until the installation is complete.
Note that you need to exit iTunes during installation.
V. Getting started with X-code and hello World
1. Open the finder, select device> disk, select the developer folder, and find and open the xcode development tool.
2. Select File> new project.
3. Select the window-based application template and select choose.
4. Enter the project name helloworld and select the Save location.
5. Add the myview class to the project.
Select File> New file. Select the objective-C class under the cocoa touch class, select uiview in the drop-down box, and click Next.
Enter "myview. M" in the name input box ".
Select the "also create" myview. H "option and click Finish.
6. select an appropriate SDK for activation.
Project> setactive SDK can be configured accordingly.
7. write the code.
Modify the "helloworldappdelegate" class so that it can use the class myview. Double-click helloworldappdelegate. M and edit the Code as follows:
Modify drawrect in myview. M: Method to output text in view.
8. Run the program.
When you are ready to debug your application, you first build your system using xcode build. If the build is correct, you can run your application in two ways: the iPhone simulator and device iPhone sdks include two SDK series:IPhone simulator SDKAndIPhone device SDK.
IPhone simlulatorsdk: The application built using this SDK runs under the iPhone simulator.
IPhone device SDK: The application built by the secondary SDK runs under the device.
The following steps are required to run your application:
A. Set the target iPhone OS version of the application.
Right-click the project on the left and choose get info.
On the build tab, select the ios sdk version.
B. Set the active SDK.
C. Click build & go to run the program.
Vi. project directory Analysis
A simple project includes the structure of class and resource:
A. Class (class) contains the application code, including the self-created class.
B. The main. m in other sources is equivalent to the main () method in Java and is the entry to the whole program execution.
C. Resource contains various resources:
XIB files are the main resources. XIB is the interface of an application, including the trigger relationships between objects and codes on the interface.
Info. plist file: contains some settings and labels of the mobile phone.
D. Framework contains the system class library.
7. iOS program simulator debugging
1. Open an existing project, find a file in the project directory on the left, and click the left button before the code to be traced and debugged. A blue arrow appears before this line of code ,.
2. Select simulator in the upper left corner.
3. Select build & go to run the program.
4. After the program starts, it will stop at the breakpoint.
5. Select Run> continue to continue running. Select Run> setp over to debug the program in one step.
6. Move the mouse over the corresponding variable, and the address and value of the variable will appear.
7. Select Run> console to bring up the console.
8. Select Run> debugger to delete the debugging window and view related information.
9. Select Run> stop to stop the program.
8. interface controls and controllers
WINDOW-BASEDAPPLICATION based
1.Add controls
Add a lable control and a button control to the window from the left objects ,:
Double-click the control to modify the text attribute of the control, or modify the attributes of the control from attributes on the right.
2.Add controller object
Under IB, select mainwindow. XIB next to the window, and select object on the library on the left,
Drag the object to the mainwindow. XIB window. The object is the controller ).
3.Generate controller class
Double-click the newly added object and enter the class name hchellocontroller in the Properties window on the right.
4. Click the gray arrow next to hchellocontroller, And the classes (class) section is displayed on the left.
5. Specify its parent class as nsobject.
6. Select "writeclassfiles..." from the File menu to generate class code for this controller.
7. You can use the default name and location, click Save, select a project, and click Add.
8. Return to xcode to write the Controller code. Check whether the interface in the. h file defines the parent class. If it does not appear in the. h file, manually add it, that is:
@ Interface hchellocontroller:/* specify a superclass (eg: nsobject
Ornsview )*/{
To:
@ Interfacehchellocontroller: nsobject {
Select File> Save to save.
9. Add properties and methods to the. h file (lable points to the text box in the window, type: uilable
The button points to the button in the window. The type is uibutton. The changewords method changes the lable text ).
10. Implement the changewords method in the. M file.
11. Associate UI objects and controllers (set TARGER-ACTION)
Double-click mainwindow. XIB to open the IB editor. Move the mouse to the hchelloconroller object, right-click and drag it to lable, and you will see a line. After selecting lable, the screen will flash,
Associate the button control in the same way.
12. Associate the button to the Controller object. Right-click the button and drag it to the Controller object. Select changewords.
13. save all the changes and run the program in xcode.
View-based application
1. Open xcode, select File> New pojects, and select View-based application.
2. Enter the project name, select the project directory, and select Save.
3. Find hcsampleviewsampleviewcontroller. XIB in the project directory, and double-click to open
4. Add one lable control and one button control on the Interface buid interface, double-click the control to modify the text property of the control, or modify the control property from the attributes window on the right of the control.
5. Return to xcode and add the Declaration in hcsampleviewsampleviewcontroller. h.
Add the implementation code in hcsampleviewsampleviewcontroller. C.
Save all changes.
6. Return to the IB interface and associate the UI object with the Controller.
Select the file's owner, right-click it, drag it to the lable control on the view, and select lable.
Select the file's owner, right-click it, drag it to the button control on the view, and select the button.
Select the button control, right-click it, drag it to file 'sowner, and select event: changewords
7. save all the changes and return to xcode. Click build and run to run the program.