IOS learning: xcode Tool

Source: Internet
Author: User
Tags gdb debugger

 

 

From: http://mobile.51cto.com/iphone-273735.htm

 

1. Powerful applications with Automatic Code Completion

When writing code in xcode, The xcode editor often provides prompts. If the code prompts meet our requirements, we can press the tab key to select the prompted code.

If the prompt Code does not meet our requirements, we can press the ESC key to display the entire prompt list and find what we need. There is a small box on the far left of the List Members. If F is in it, the corresponding member is a function; if M is in it, it is a method; if it is #, It is a # define command; if it is e, it indicates enumeration; if it is C, it indicates class.

If you do not want to display the prompt list, you can select between Members in the list. You can use the shortcut key control +. loop between options, or SHIFT + Control +. Reverse loop between options. We can use the "Automatic Code Completion function" to query the APIs (interface methods) provided by a class ). The method is to write the class in the method call expression to implement this query function:

[Nsdictionary + space, and then press the ESC key to display the list of methods provided in nsdictionary. Note: [nsdictonary must be followed by spaces, prompting that the name of the Compiler class has been written. Next, enter the message (that is, the method name in the class ).

The shortcut to jump the cursor from a placeholder to the next placeholder is: Control +/

 

 

 

2. Obtain xcode documents and references through research assistant.

You can use help-> show research assistant to open the research assistant. Once the floating window of the research assistant is opened, the content in the floating window will change as you interact with xcode.
As shown in: in the tire. M file, when the cursor is in the nsstring class, study the information displayed in the floating window of the assistant:

Switch to the tire. h file, and the floating window of the study assistant will display information about nsobject:

 

 

 

 

3. Document Management Program

You can access Apple's official API documentation by holding down the option key and double-clicking a symbol to view. For example, press and hold the option key and double-click the nsstring symbol to open information about nsstring in the document browser window, such:

 

 

 

4. How to debug the program?

(A) There are two methods: Brute Force debugging and debugger debugging.

What is brute force debugging?

Brute-force debugging adds the nslog () language to your program, and outputs the program control flow and some important data to the terminal.

 

Debugger debugging:

The debugger is a program between the application you write and the operating system. It can control your program, such as stop, execute, and single-step tracking.

The debugger used by xcode is GDB.

In addition to GDB, xcode also has a micro-debugger, which is a floating window through which we can skip the gdb debugger for some simple debugging.

Xcode has a debugging window that provides a large amount of summary information.

Xcode provides a debugging console through which Debugging commands can be directly sent to the debugger.

(B) How to debug with a debugger?

(1) When compiling a program, you must use the debug configuration of the compiler. In this way, the compiled program contains debugging information (information used by the debugger)

(2) The program must be run in Debugger Mode during debugging.

There are two methods to run the program in xcode: Run-> Run (shortcut: Command + r), without the need to run the program using a debugger;

Run-> go (Debug) or run-> debug (shortcut: Command + Y), run the program using the debugger.

 

(3) How do I set a breakpoint?

Click the edge column (gutter) to set a blue breakpoint. the breakpoint is disable at the next click. If you want to delete the breakpoint, the breakpoint is dragged out of the edge column.

Debugging shortcut:

  1. Continue: Option + command + P
  2. Step into: Shift + command + I
  3. Step over: Shift + command + O
  4. Step out: Shift + command + T

Open the debugging window of xcode (click a box with a sprayer on the debugging control bar), for example:

In this window, you can execute various Debugging commands and observe the changes in variable values.

The following is the command debugging window of GDB. You can enter the DEBUG command of GDB to debug the program:

You can view the function call stack by debugging a control on the control bar (the one on the right of the control in the black box), as shown in.

[Note] the narrow column of the edge column (the column where the breakpoint is located) is the focus column.

 

 

 

 

 

 

 

 

 

 

 

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.