【发布时间】:2013-07-15 10:24:57
【问题描述】:
我目前正在学习 Objective-C,需要知道如何编写方法描述。我在学习如何在 Objective-C 中做到这一点时遇到了很多困难。
在 Jave 中我们有这个
/**
< h2 >MethodName</ h2 >
< p >Various Description, can use html with images etc.</ p >
*/
private void methodName(args[]..)
{
}
在objective-c中我在哪里放置描述?这也是在头文件中还是在实现文件中?
//Within Implementation?
- (float)gteHeightPercentage:(float)percentageToGet
{
return self.view.bounds.size.height * percentageToGet;
}
//Within Header?
- (float)getWidthPercentage:(float)percentageToGet;
【问题讨论】:
-
“描述”是指接口还是实现?您将在代码中显示其中一个。
-
我相信“描述”是指“文档”。
-
我的意思是简单的方法描述,即当按住“alt”并显示方法的作用时。
-
这就是你说的那种东西吗? stackoverflow.com/questions/174315/…
-
持有“alt”是IDE特性,与Objective-C语言无关。在 .h 文件中,您放置(按照惯例)“接口”。它包含类的外部声明,例如“//Within Header?”之后的行更多。在 .m 文件中,在“实现”内,放置方法的定义,例如在“//在实现内?”之后的定义。接口定义了类的外部,实现定义了它的内部工作方式。 (这类似于 C、C++ 和许多其他语言的做法。)
标签: objective-c xcode documentation comments