break label usage in Objective-C and Java

if you have nested for loop or the for loop need to be break in special condition
use 'break label' can satisfy your demand

●Java
myForLoop: {
    for (; ; ;) {
if(someCondition == True)
            break myForLoop;
    }
}

Objective-C
for (;;)
{
    for (;;)
    {
        break; /* breaks inner loop */
    }
    for (;;)
    {
        goto myForLoop; /* breaks outer loop */
    }
}
myForLoop:;

沒有留言: