这是什么 Objective-C/XCode 注释//[START_EXCLUDE] [英] What is this Objective-C/XCode annotation // [START_EXCLUDE]

查看:18
本文介绍了这是什么 Objective-C/XCode 注释//[START_EXCLUDE]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处查看 iOS 上 GCM 通知的示例代码:https://github.com/googlesamples/google-services/blob/master/ios/gcm/GcmExample/AppDelegate.m#L31

Looking at sample code for GCM notifications on iOS found here: https://github.com/googlesamples/google-services/blob/master/ios/gcm/GcmExample/AppDelegate.m#L31

....
// [START register_for_remote_notifications]
- (BOOL)application:(UIApplication *)application
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // [START_EXCLUDE]
      ....
      // [END_EXCLUDE]

//[START_EXCLUDE]//[END_EXCLUDE] 服务的目的是什么.它是约定的一部分、Objective C 的一部分还是 xCode 的某些内容?

What purpose do the // [START_EXCLUDE] // [END_EXCLUDE] serve. Is it part of a convention, part of Objective C or something for xCode?

推荐答案

它是约定的一部分、Objective C 的一部分还是 xCode 的某些内容?

Is it part of a convention, part of Objective C or something for xCode?

以上都不是. 就编译器而言,这些只是注释——它们不是任何标准 Objective-C 约定的一部分,也不是语言的一部分、编译器可以理解的指令,或者 Xcode 可以理解的指令.

None of the above. Those are just comments as far as the compiler is concerned -- they aren't part of any standard Objective-C conventions, and they're not part of the language, directives that are understood by the compiler, or instructions understood by Xcode.

从 repo 中的一些提交注释来看,[START ...][END ...] 似乎是某种预处理器的指令,但在您构建项目时不会触发该预处理器.也许它们由项目外部的工具使用,该工具可用于生成具有特定选项集的示例代码.如果您仔细查看代码,您会发现类似的指令,例如:

From some of the commit comments in the repo, the [START ...] and [END ...] seem to be directives to some sort of preprocessor, but that preprocessor isn't triggered when you build the project. Perhaps they're used by a tool that's external to the project, one that can be used to generate sample code with specific sets of options. If you look through the code, you'll find similar directives, such as:

// [START start_gcm_service]
...
// [END start_gcm_service]

而且这些似乎都围绕着可能从代码中删除的代码块.

and these all seem to surround chunks of code that might be excised from the code.

这篇关于这是什么 Objective-C/XCode 注释//[START_EXCLUDE]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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