Implementation of IOS with parametric function body and non-parametric function body and Xcode single step debugging

Source: Internet
Author: User

Here is a simple example, for everyone's understanding, the use of single-step debugging

The one-step debugging in Xcode is very useful, and we can use it to correct the program.

It's easy for us to find the root of the error, a skill that programmers must have

To solve the problem we need to set a breakpoint, and then one step to debug, encountered the method body, we can jump into the

Method body, so that we find the change of each variable value, and the concrete steps of the function implementation

A clearer understanding of the steps we have written to execute the program

First I put the simple code out, although simple, but we must master the power of debugging

Defines a Calcultor class

There are two member variables

There are two ways of

Main.m

#import <Foundation/Foundation.h> #import "Calcultor.h" int main (int argc, const char * argv[]) {    Calcultor * cal = [[Calcultor alloc]init];        [Cal Seta:10];    [Cal Setb:20];        NSLog (@ "%d", [cal Add]);        NSLog (@ "%d", [Cal Sub:10 Andb1:10]);    return 0;}

Calcultor.h

#import <Foundation/Foundation.h> @interface calcultor:nsobject{    int _a;    int _b;} @property int A; @property int b;-(int) add;-(int) sub: (int) A1 ANDB1: (int) B1; @end

Calcultor.m

#import "Calcultor.h" @implementation calcultor-(int) add{    return _a + _b;    NSLog (@ "A+b");} -(int) sub: (int) A1 ANDB1: (int) B1; {    //_a = A1;    _b = B1;    return _a + _b;} @end

First step: Set breakpoints


Step two: Command + R starts execution

Into the debug state, we can see there is a debug window at the bottom left, there is no execution, so the initial value of a B is 0, here is called the parent class constructor method to assign a value to the member variable

The third step is to perform one-step debugging as follows:


Fourth step: Enter inside the function body


Fifth step: Enter the inside of the Add function body


Sixth step: Click Next to jump out of function body back to main function


Share with us useful dry foods and learn together


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Implementation of IOS with parametric function body and non-parametric function body and Xcode single step debugging

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.