Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some no op operation in objective-c that we can use just to set breakpoint

The code shouldn't have any effect It should be doable anywhere It doesn't generate compiler warning

Basically sometimes I want to do NSAssert. However, rather than NSAssert, I sometimes want to do my if {} my self. That way I can just easily set or unset the break point

Currently this is what I do.

if (entityName==@"Business")
{
    error=nil; //Some code for breakpoint. I want something that do nothing actually.
}

It's just happen that I have a variable named error that I will no longer use. But what would be a goodalternative

I also tried [nil donothing]; but that got compiler error.

like image 954
user4951 Avatar asked Sep 25 '12 08:09

user4951


1 Answers

Try this:

while (false);

There are other possibilities, like if (false) or even just a line with a lone semicolon ;, but in those cases execution stops at the next instruction, possibly because the compiler simply eliminates those empty bits of code. Using while has the advantage that execution will stop on that line (assuming you put a breakpoint there, of course).

like image 61
Caleb Avatar answered Sep 20 '22 07:09

Caleb