“return” from method while stepping?

后端 未结 3 1631
抹茶落季
抹茶落季 2021-01-11 11:42

I would like to exit out the current method that I\'m stepping through.

-(void)helloWorld {
    NSLog(@\"Hello\");
    // I would like to return here, so tha         


        
相关标签:
3条回答
  • 2021-01-11 12:24

    When you are debugging using Xcode and when your program is paused at a breakpoint, you can drag the little green arrow to any other line in the function. E.g. in the following code:

    Xcode breakpoint

    if I want to skip the NSLog(@"B"), I can simply drag the green arrow from line 20 to line 23, which means the function will simply "return" from anywhere I want.

    0 讨论(0)
  • 2021-01-11 12:28

    I just added a breakpoint at the line mentioned below:

    var computed: Bool { 
       return device.time == 10 // added breakpoint here
    }
    

    and got the following error:

    error: Error returning from frame 0 of thread 1: We only support setting simple integer and float return types at present..

    Seems to work for only those two types

    0 讨论(0)
  • 2021-01-11 12:43

    Unfortunately in Xcode 4.5.x there is no way to force an early return from a function. In the current lldb sources over at http://lldb.llvm.org/ there is a newly added command, thread return, which does what you want - it includes the ability to specify the return value of the function. This won't be in Xcode until the next major release, though.

    0 讨论(0)
提交回复
热议问题