Search code examples
objective-cxcodelldb

"return" from method while stepping?


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 that "World" isn't printed.
    NSLog(@"World");  
}

I have tried the following, but without luck.

(lldb) expr return
<no result>

Is this possible with lldb?


Solution

  • 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.