Create a OBJECT-C program
Enter the main interface mode : After you open Xcode, you can use the Xcode menu, but you must create a OBJECT-C project or import a object-c project to enter the main interface;
-- Open Existing Project : Click on the historical record on the right to open the existing project;
-- Create a project : Click the first create a new Xcode project to create a project;
-- Import Project : Click Check out a existing project can import a project that has already been created;
Create a command-line program : Select the OS X--and command line Tool program that creates the project interface, which creates a command-shell, COCOA application is a program that creates an interface;
-- iOS Project : iOS project is the app for mobile phone and tablet development;
OS X Project : OS X is an application created for the OS operating system;
Create Project : Indicate project name, company name, type;
-- Product name: project title;
- Organization Name: Name of the organization;
-- Type : Here Select Foundation, this is Object-c project;
Create an IOS project
Open Xcode and choose Create New Project : Pop-up menu, select IOS--Single View application project;
fill in the project information :
-- Product name: project title;
-- Organization Name : company logo;
--Class Prefix : In order to avoid the user-defined class and the Object-c class naming conflict problem, the prefix is added before each class;
-- Devices : Select the device that the app is running on, Universal says the colleague is compatible with ipad and iphone;
Xcode Interface Detailed
1. Introduction to the Xcode interface
(1) Top section
program Run related :
-- from left to right : Run button, stop button, select the operating platform for the project;
Editor-related :
-- from left to right : Standard editor, Auxiliary editor, version editor;
Panel control related :
-- from left to right : Hide left panel, hide bottom Panel, hide right panel;
(2) left panel
Panel Description : The panel is the Xcode Project navigation panel, the top seven buttons for switching navigation mode;
(3) Bottom panel
Panel Description : For Xcode display console debug output information;
(4) Right panel
Inspector panel : contains a large number of reviewers depending on the project;
Library Panel :
-- Library panel introduction (from left to right) : File Template Library, code Snippets Library, object library, Media Library;
(5) Detailed editing area
This area is the code authoring main area :
2. Detailed Navigation panel
Introduction to the navigation panel :
-- from left to right : Project navigation, symbol navigation, search navigation, problem navigation, test navigation, debug navigation, breakpoint navigation, log navigation;
(1) Project navigation
Project Navigation consists of:
-- source file : the ". H" and ". M" suffix files in the HelloWorld directory are source files;
-- Properties file : Under the HelloWorld supporting files directory is a property file picture, etc.;
-- Unit test Project : HelloWorldTest is the unit test project of the project;
-- Target application : The Helloworld.app in the products catalogue is the target application;
(2) Symbol navigation
Introduction to Symbolic navigation : Displays the classes, items and attributes in the project with symbols;
-- representation : C represents a class, M represents a method, P represents a property;
-- Quick positioning : Click on the corresponding method or property, can quickly locate in this class;
(3) Search navigation
Search Navigation Introduction : Enter the string to search in the search box, press ENTER to search out the class containing the string;
(4) Problem navigation panel
Introduction to the problem navigation panel : Displays warnings or errors that exist in the project;
(5) Test navigation
Introduction to test navigation : Click the Execute button after testexample to run the unit test;
(6) Debug navigation
Debug Navigation Introduction : The debug navigation panel shows the details of each thread;
Add Breakpoint : Add a breakpoint in OCTVIEWCONTROLLER.M;
Start Debugging (Automatic judgment) : Click the Debug button in the top panel, if the code has a breakpoint, it will automatically enter the debugging state, execution to the breakpoint will automatically stop, detailed debugging information displayed in the bottom of the debug output panel;
Debug Panel Introduction : The following from left to right introduction;
-- Continue program execution : Continue to execute the following code;
Step over: Single-step debugging, click the button once, execute a line of code, if there is a method call, will not enter the method;
-- STRP in: Step Into the debugging, click the button, will enter the method;
Step out: Stepping out of debugging, in the method, click on the button, will exit the method, the execution of a single step outside the method of debugging;
(7) Breakpoint navigation
Introduction to Breakpoint navigation : Lists all breakpoints to facilitate the management of breakpoints;
(8) Log navigation
Log Navigation Introduction : List the project development process, build, build, run the process, each time the process can be viewed through the log panel;
3. Inspector Panel
Check Panel categories :
-- Common source files : Include File Checker and quick helper;
-- Story version : interface files, in addition to File Checker and quick Helper, there are identity checker, property inspector, size checker, connection checker;
File Checker :
-- Identity and Type : file name (filename), file type, full path (path);
-- text Settings : Text Encoding (file encoding using character set), Indent using (indent), wrap lines (wrap);
Quick Helper : When you rest your cursor in the system class, the panel displays a reference manual for that class, using the Guide and sample code;
interface Design Related checker : When a user selects a file with ". Storyboard" or ". Xib" suffix, additional four inspectors will be added;
-- Identity Checker : Management interface Component Class implementation class, restore ID and other identity attributes;
-- Property Inspector : Manage the interface component stretching mode, background color and other properties;
-- size checker : Manage interface components such as width and height xy axis coordinates and other properties;
-- Connection Checker : The relationship between the management interface component and the program code;
4. Library panel
Library Panel Introduction : From left to right introduction;
-- File Vault template : Manage file templates to quickly create files of the specified type, which can be dragged directly into the project;
-- Code Snippets Library : Manages various code snippets, which can be dragged directly into the source code;
-- Object Library : interface components can be dragged directly into the storyboard;
-- Media Library : Manage various kinds of pictures, audio and other multimedia resources;
Xcode Help System detailed
Help system role : The object-c development needs to call many system classes, need to understand the use of each class, through the Xcode Help system can query the use of these classes;
1. Quick Help Panel
The quick Panel display content in the right panel: the class inherits the parent class, follows the agreement, the class is in the frame, clicks the link in the reference, can enter the class detailed introduction;
Class Details page : Through the quick Help panel in the Reference in the link, you can enter the page;
class Method Classification interface : The interface with the detailed interface is the same, pull down;
2. Direct Search
Search : Through any link into the class details of the interface, you can enter a keyword in the above input box to search for related classes, methods, protocols or functions;
3. Code Automatic Hints
hint : The code editing area, holding down the option key, and then moving the cursor to the class, will become a question mark, click will appear the following prompt box;
1. File extension Introduction
C language source file suffix : ". C";
C + + language source file suffix : ". CC", ". cpp";
header file : ". h";
object-c source program : ". M";
object-c++ source program : ". MM";
c/c++/object-c/object-c++ generated intermediate file : ". O";
c/c++/object-c/object-c++ generated executable file : ". Out";
2. Program source code and analysis
Program source code :
/* Import the Foundation.h file under the Foundation framework */#include <foundation/foundation.h>/* program entry function */int main (int argc, char * argv []) {/* Automatically frees the pool, the statements executed in that environment will automatically reclaim the created object */@autoreleasepool {/* * in the Foundation output function, output string, object etc. */nslog (@ "Hello world");/* @ "Hel Lo World ", plus @ is to differentiate */}return 0 from strings in C;}
(1) Import frame header file
Import Header file statement : #import <a/b.h> is the b.h header file in the import a framework;
Framework Introduction : The framework is a collection of class functions, Cocoa QuickTime is encapsulated as a framework, Cocoa includes the Foundation and application kit and other components;
(2) Automatic release of the pool
Memory Management : In the early object-c need to manually manage the allocation and recycling of memory, OBJECT-C 2.0 introduced ARC (automatic reference counting) and automatic release pool , not manual memory management;
Auto-free pool : The code that uses the "@autoreleasepool {}" package is located in Object-c's auto-release pool, which automatically reclaims the created objects without manual memory management;
(3) String output
NSLog () function : This function is a function provided by the Foundation framework, which can output string objects and so on;
-- NS prefix description : All class function constants in the COCOA framework are prefixed with NS;
- @ "string" description : the @ symbol is used to differentiate between object-c and C strings, plus the object-c string at the @ symbol;
3. Compiling the Run code
LLVM Clang compiler Syntax : Clang-fobjc-arc-framwork Framework Name source program-O output result;
-- -fobjc-arc parameter : Enable the Arc automatic technology function of object-c;
--- o parameter : If not, the default output a.out;
compile the 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
Some of the commands that are useful in lldb (the debug bar underneath Xcode)
Print Help
Print Call stack
Print the most basic content (p)
Print Object (PO)
Print expression (expr)
Some things in the print thread
lldb Common commands
If you are going to run this in the simulator, you can enter the following in the "(LLDB)" Prompt:
(LLDB) PO $eax
LLDB is the default debugger in xcode4.3 or later versions. If you are using an older version of Xcode, you are also GDB debugger. They have some basic same commands, so if your xcode uses a "(GDB)" hint instead of a "(LLDB)" Hint, you can do it more, without problems.
The "po" command is shorthand for "print object". "$eax" is a register of Cups. In the case of an exception, this register will contain a pointer to an exception object. Note: $eax will only work in the emulator, if you debug on the device, you will need to use the "$r 0″ register.
For example, if you enter:
(LLDB) PO [$eax class]
You will see something like this:
(ID) $ = 0x01446e84 NSException
These numbers are not important, but it is clear that the NSException object you are dealing with is here.
You can call any method on this object. For example:
(LLDB) PO [$eax name]
This will output the name of the exception, here is the nsinvalidargumentexception, and:
(LLDB) PO [$eax reason]
This will output an error message:
(unsigned int) $4 = 114784400 Receiver () have no segue with identifier ' Modalsegue '
Note: When you use only the "Po $eax", this command will call the "description" method and print out the object, in which case you will get the wrong message.
Utility LLDB Command
Command name Usage description
|
| Expr |
Expr expression |
A useful command that can dynamically execute a specified expression and print the result at debug time. |
| Po |
PO Expression |
Similar to expr, the object description method is called when the object is printed. It's a shorthand for print-object . |
| Print |
Print (type) expression |
is also a print command, you need to specify a type. |
| Bt |
BT [ALL] |
The print call stack is a shorthand for the thread BackTrace , plus all to print the stack of all the thread. |
| BR L |
BR L |
It's a shorthand for the breakpoint list . |
| Process Continue L |
Process continue |
Shorthand:C |
| Thread step-in L |
Thread step-in L |
Abbreviation:s |
| Thread Step-inst L |
Thread Step-inst L |
Abbreviation:si |
| Thread Step-over L |
Thread Step-over L |
Shorthand:n |
| Thread Step-over-inst L |
Thread Step-over-inst L |
Abbreviation:ni |
| Thread Step-out L |
Thread Step-out L |
Abbreviation:f |
| Thread List |
Thread List |
Abbreviation:th l |
memory leak hidden hint:
Potential Leak of an object allocated in line ...
data assignment hidden hint:
The left operand of ... is a garbage value;
object reference hidden hint:
Reference-counted object is used after it is released;
for retain, copy, Init, Release , Autorelease, etc. in the count of the use of the situation of the detailed explanation, recommend:
Http://www.cnblogs.com/andyque/archive/2011/08/08/2131236.html
Call Autorelease This means that you can use Vari in this function, but once the next run loop is called, it will be sent to the release object. Then the reference count is changed to 0, then the memory is freed. (As for how autorelease works, my understanding is that each thread has a autoreleasepool stack, which puts a lot of Autoreleasepool objects in it.) When you send a autorelease message to an object, the object is added to the Autoreleasepool at the top of the current stack. When the current Runloop is finished, the pool is destroyed and the release message is sent to all the Autorelease objects inside it. The Autoreleasepool is created at the beginning of the current runloop and pressed into the top of the stack. So what is a runloop? A UI event, a Timer call, a delegate call, will be a new runloop. )
Introduction to the Xcode interface