遇到& quot;清理:& quot;在Xcode中的Foundation代码示例中.这是什么? [英] encountered "cleanup:" in a Foundation code sample in Xcode. What is this?

查看:53
本文介绍了遇到& quot;清理:& quot;在Xcode中的Foundation代码示例中.这是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此在即将发布的 Core Audio Book 我遇到了一个陌生的符号

so in some sample code from this upcoming Core Audio Book i've encountered an unfamiliar symbol

cleanup:

在调用某些dispose(myStuff)函数之前使用.它前面没有'@'或'#'.似乎您可以输入任何单词,后跟冒号,它会像注释一样起作用吗?

which is used before some dispose(myStuff) functions are called. It's not preceded by an '@' or a '#'. Seems you can type any word, followed by a colon, and it will act like a comment?

int main (int argc, const char * argv[])
{
    @autoreleasepool 
    {
        NSLog(@"i am code.");

    cleanup:    
    foop:
    lol:

        NSLog(@"even more code.");
    }
    return 0;
}

推荐答案

这不是评论.这是一个标签,用于指定 goto 的位置.

It's not a comment. It's a label specifying a location for goto.

例如

int main (int argc, const char * argv[])
{
    while (1) {
        printf("Is this an infinite loop?\n");
        goto endLabel;
    }

    endLabel:    

    printf("No.");

    return 0;
}

输出:

Is this an infinite loop?
No.

这篇关于遇到& quot;清理:& quot;在Xcode中的Foundation代码示例中.这是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆