breakpoints

Discussion in 'iOS Programming' started by man2manno, Aug 1, 2009.

  1. man2manno macrumors member

    Joined:
    Mar 21, 2009
    #1
    Hey guys,
    I am stuck and I am just wondering how to create breakpoint. For example,
    I have an if statement and if a certain thing happens I want the method to break so that the rest of the code in that method will not run. Can anyone help please?

    Code:
    Code:
    if ([inputName.text isEqualToString:@""]) {
          //break code;
    }
    
     
  2. EdoDodo macrumors newbie

    Joined:
    Aug 1, 2009
    #2
    Well if you mean a breakpoint as in the code stops so you can debug it then it depends on your IDE, in X-Code you have to click on the far left of the editing window (the "gutter") at the point where you want the code to stop. You can check out the X-Code debugging guide for more information:
    http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeDebugging/index.html

    If by breakpoint you mean that the function ends then you can just return a value (depending on what the function is meant to return) or if you want to simply end the if statement then "break;" will do the trick.
     
  3. man2manno thread starter macrumors member

    Joined:
    Mar 21, 2009
    #3
    Ya, I just mean that I want the function to end, I don't think breakpoint was the proper word for that. What I am trying to do is more like the "break;" command.

    However, I get an error when I put "break;" into an if statement telling me that its looking for a loop statement not an if.

    Any ideas?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    If you want the method to stop executing, call return;
     
  5. man2manno thread starter macrumors member

    Joined:
    Mar 21, 2009
    #5
    Alright I get what your saying but what if the if statement is in an IBAction function such as a button? Can you still return a value? And if so what do u return?
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    IBAction doesn't return a value. IBAction is just a special keyword that actually means the same thing as void. And voids don't return values. If you want to stop execution of some other type of method, though, just be sure to return a value of the type that is defined as the return type for that method.

    Hmm, unless you are wanting your IBAction to return a value. Is that the case? If so, please explain why you need to do this.
     
  7. man2manno thread starter macrumors member

    Joined:
    Mar 21, 2009
    #7
    Ohh right right. I see what you are saying. I got it working. Thank you very much for your help.
     

Share This Page