Object-C getting started Xcode environment details, object-cxcode

Source: Internet
Author: User

Object-C getting started Xcode environment details, object-cxcode

Author:Han shuliang

Reprinted please indicate the source: Http://blog.csdn.net/shulianghan/article/details/38424965


I. Installation and Project Creation in Xcode Environment



1. Download Environment


Download related resources:

--IOS-related information Download Page: Https://developer.apple.com/devcenter/ios/index.action;

--Xcode Download Page: Https://developer.apple.com/xcode/downloads;



2. Create an Object-C program


Access the main interface: After Xcode is enabled, you can use the Xcode menu. However, you must create an Object-C project or import an Object-C Project to access the main interface;

--Open an existing project: Click history on the right to open an existing project;

--Create a project: Click the first Create a new Xcode Project to Create a new Project;

--Import Project: Click Check out an existing project to import a created project;



Create a command line program: Select the OS X --> Command Line Tool program on the Project Creation page to create a Command Line program. The Cocoa Application is a program with an interface;

--Ios Project: The ios project is an application developed for mobile phones and tablets;

--OS X Project: OS x is an application created for the OS;



Create a project: Enter the project name, company name, and type;

--Product Name: Project name;

--Organization Name: Organization name;

--Type: Select Foundation. This is the Object-C Project;




3. Create an IOS Project


Open Xcode and select create new project: Select IOS --> Single View Application project in the pop-up menu;



Enter project information:

--Product Name: Project name;

--Organization Name: Company logo;

--Class Prefix: To avoid conflicts between user-defined classes and Object-C classes, add this prefix before each class;

--Devices: Select the device where the application runs. Universal indicates that colleagues are compatible with ipad and iphone;



Ii. Xcode Interface Details


1. Xcode interface Introduction




(1) top area


Program running:

--Introduction from left to right: Click "run" and "stop" to select a running platform for the project;


Editor Problems:

--Introduction from left to right: Standard editor, auxiliary editor, and version editor;


Panel control problems:

--Introduction from left to right: Hide the left panel, the bottom panel, and the right panel;



(2) left panel




Panel Introduction: This panel is the Xcode project navigation panel. The seven buttons above are used to switch the navigation mode;



(3) Bottom panel




Panel Introduction: Used to display the debugging output information of the console in Xcode;



(4) right panel


Checker panel: Contains a large number of reviewers, depending on the project;



Database panel:


--Database panel Overview (from left to right): File template library, code snippet library, Object Library, and media library;



(5) detailed editing area


This area is the main area for coding:






2. Navigation Panel details


Navigation Pane Overview:

--From left to right: Project navigation, symbol navigation, search navigation, problem navigation, test navigation, debugging navigation, breakpoint navigation, and log navigation;


(1) Project navigation




Project navigation:

--Source File: The ". h" and ". m" Suffixes in the HelloWorld directory are source files;

--Property File: The Supporting Files directory under HelloWorld contains attribute file images;

--Unit test item: HelloWorldTest is a unit test project of the project;

--Target Application: HelloWorld. app in the Products directory is the target application;



(2) symbol navigation




Introduction to symbol navigation: Use symbols to display classes, projects, and properties in the project;

--Representation: C indicates a class, M indicates a method, and P indicates a property;

--Quick Positioning: Click the corresponding method or attribute to quickly locate the class;



(3) search and navigation



Search navigation Overview: Enter the string to be searched in the search box, and press enter to search for the class containing the string;



(4) problem navigation panel




Problem navigation panel Introduction: Displays warnings or errors in the project;



(5) test navigation




Test navigation Overview : Click the execution button next to testExample to run the unit test;



(6) debug navigation




Debugging navigation Overview: Detailed information about each thread is displayed on the debug navigation panel;


Add breakpoint: Add a breakpoint to OCTViewController. m;



Start debugging (automatic judgment): Click the debug button on the top panel. If there is a breakpoint in the code, it will automatically enter the debugging status. When the breakpoint is executed, it will automatically stop. The detailed debugging information is displayed on the debug output panel at the bottom;



Debugging panel Introduction: The following is an introduction from left to right;

--Continue program execution: Continue to execute the following code;

--Step over: For single-step debugging, click this button once to execute a line of code. If there is a method call, it will not enter the method;

--Strp in: Step into Debugging. Click this button to enter the method;

--Step out: Step-out debugging. In the method, click this button to exit the method and perform one-step debugging outside the method;



(7) breakpoint navigation




Introduction to breakpoint navigation: Lists All Breakpoints to facilitate breakpoint management;



(8) log navigation




Log navigation Overview: Lists the processes of building, generating, and running a project during development. You can view the process on the log panel each time;





3. Checker panel


Check panel category:

--Common source file: Includes the File Checker and quick helper;

--Story Edition: Interface files, in addition to the File Checker and quick helper, also include the identity checker, attribute checker, size checker, and connection checker;


File Checker:


--Identity and Type: File Name (File Name), File Type (File Type), Full Path (Path );

--Text Settings: Text Encoding (character set used for file Encoding), Indent Using, and Wrap lines (automatic line feed );


Quick help: When you move the cursor over the system class, the panel displays the reference manual, user guide, and sample code for this class;




Interface Design related checker: When you select a file with the suffix ". storyboard" or ". xib", there will be four more check servers;


--Identity checker: Management Interface Component class implementation class, restoration of ID and other distinguished attributes;

--Property checker: Manage attributes such as the interface component stretching mode and background color;

--Size checker: Manage attributes such as page component width and height xy axis coordinates;

--Connection checker: Manage the associations between interface components and program code;



4. Database panel




Database panel Introduction: From left to right;

--File library Template: Manage File templates. You can quickly create a specified type of files and drag them directly into the project;

--Code snippet Library: Manages various code snippets and can be directly dragged into the source code;

--Object Library: Interface components, which can be directly dragged into the story board;

--Media Library: Manages various multimedia resources such as images and audios;



Iii. Detailed explanation of Xcode Help System


Help system functions: Many System Classes need to be called in Object-C development. You need to understand the usage of each class. You can use Xcode to help the system query the usage of these classes;



1. Quick help panel




Content displayed on the quick panel on the right panel: The parent class inherited by this class, the Protocol followed, and the framework of the class. Click the link in Reference to go to the class details;


Class details page: You can access this page through the link in Reference in the quick help panel;



CATEGORY Interface: This interface is the same as the detailed interface. drop-down is enough;



2. Search directly


Search: After entering the class details page through any link, you can enter keywords in the input box above to search for related classes, methods, protocols, or functions;



3. Automatic code prompt


Tip Mode: In the code editing area, hold down the option key and move the cursor over the class. The question mark is displayed. The following prompt box is displayed when you click it;




4. Hello World Program



1. File Extension Introduction


C source file suffix: ". C ";

C ++ source file suffix: ". Cc", ". cpp ";

Header file: ". H ";

Object-C source code: ". M ";

Object-C ++ source code: ". Mm ";

Intermediate file generated by C/C ++/Object-C ++: ". O ";

Executable files generated by C/C ++/Object-C ++: ". Out ";



2. program source code and Analysis


Program source code:

/* Import the Foundation under the Foundation framework. h file */# include <Foundation/Foundation. h>/* program entry function */int main (int argc, char * argv []) {/* Automatically releases the pool, the statements executed in this environment will automatically recycle the created object */@ autoreleasepool {/* the output function in Foundation, which can output strings, object */NSLog (@ "Hello World");/* @ "Hello World", add @ to distinguish it from the string in C */} return 0 ;}


(1) import the framework header file


Header file Import Statement: # Import <a/B. h> is the header file for importing B. h in framework;


Framework Overview: The Framework is a collection of class functions. Cocoa QuickTime is encapsulated into the framework. Cocoa includes components such as Foundation and Application Kit;



(2) automatically release the pool


Memory Management: In the early stage, Object-C needs to manually manage memory allocation and recovery. Object-C 2.0 introducesARC (automatic reference count)AndAuto Release pool, Does not perform manual memory management;


Auto Release pool: The Code wrapped in "@ autoreleasepool {}" is located in the automatic release pool of Object-C. These statements will automatically recycle the created objects without manual memory management;



(3) string output


NSLog () function: This function is a function provided by the Foundation framework. It can output string objects;

--NS prefix description: All class function constants in the Cocoa framework are prefixed with NS;

--@ "String" DescriptionThe @ symbol is used to distinguish between Object-C and C language strings. When the @ symbol is added, the Object-C string is used;



3. Compile and run the code


LLVM Clang compiler syntax: Clang-fobjc-arc-framwork framework name source program-o output result;

---Fobjc-arc Parameters: Enable the automatic ARC feature of Object-C;

---O Parameters: If not, a. out is output by default;


Compilation execution result:

octopus-2:ios octopus$ clang -fobjc-arc -framework Foundation 01-HelloWorld.m octopus-2:ios octopus$ ls01-HelloWorld.ma.outoctopus-2:ios octopus$ ./a.out 2014-08-10 00:22:55.670 a.out[3394:507] Hello World




Author:Han shuliang

Reprinted please indicate the source: Http://blog.csdn.net/shulianghan/article/details/38424965



Is there any book suitable for beginners to read Xcode Object-c that is highly readable in the Chinese version? Urgent

Yes. The book "getting started with Cocoa-using Objective-c" is Chinese. It is good and suitable for beginners.

Without any C language, how can we quickly learn Object-C or understand it?

Code is secondary. The key is to understand the structure. iphone is a platform that doesn't matter. The programming ideas are the same. There is no big difference.
The key to getting started is thinking. You ask your father. Much better. Some people may not understand programming for years.
By thinking about other things, it's enough to remember external branches. It's enough to give you an introductory textbook that is useless. For programming cognition, you need to understand what is in books by yourself, and it cannot bring to beginners. this is useless.

The shortcut is that you have to find a master who can get you started. Of course, this entry is an idea, not a syntax api, iphone or something.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.