Oli*_*xon 21 documentation xcode comments objective-c
我目前正在学习Objective-C,需要知道如何编写方法描述.在Objective-C中学习如何做到这一点我遇到了很多困难.
在Jave,我们有这个
/**
< h2 >MethodName</ h2 >
< p >Various Description, can use html with images etc.</ p >
*/
private void methodName(args[]..)
{
}
Run Code Online (Sandbox Code Playgroud)
在objective-c中,我在哪里放置描述?这也是在头文件或实现文件中?
//Within Implementation?
- (float)gteHeightPercentage:(float)percentageToGet
{
return self.view.bounds.size.height * percentageToGet;
}
//Within Header?
- (float)getWidthPercentage:(float)percentageToGet;
Run Code Online (Sandbox Code Playgroud)
Q8i*_*Q8i 63
更新:以下格式适用于Objc.如果您想记录swift代码,请参阅NSHipster关于Swift文档的博客
XCode 5可以做你想要的.感谢Wonil Kim,在.h文件中:
/**
* Add new message between source to destination timeline as empty name string
* @author Wonil Kim
*
* @param sourceId Source timeline entity ID
* @param destId Destination timeline entity ID
* @return A newly created message instance
*/
- (ISMessage*)messageFromTimeline:(NSInteger)sourceId toTimeline:(NSInteger)destId;
Run Code Online (Sandbox Code Playgroud)
完成后,您可以alt+点击方法名称,然后......瞧!
/*! Some description of the method....
* \returns The result
*/
Run Code Online (Sandbox Code Playgroud)
或者,
/// Some description to show up, done by:
/// @author Olly Dixon
Run Code Online (Sandbox Code Playgroud)
你明白了......
As many already have mentioned, Objective-C does not show you your documentation; in fact, neither does java (javadoc, may be). It's your IDE, in this case, the un-crashable Xcode :)
UPDATE2: Complete list of "Special Commands" in comments.
UPDATE3: Use VVDocumenter-Xcode if you'd like to enable auto-generation of documentation by ///.
UPDATE4:: VVDocumenter has be integrated in to Xcode:
Use the shortcut (⌥ Option + ⌘ Command + /) to add a documentation comment to your code if you are using Xcode 8 or above
您所描述的内容简称为"文档注释"或"文档注释".
从版本4.6.3开始,Xcode不会在弹出窗口或其快速帮助检查器中显示您自己的文档注释.您必须将注释编译为"docset"以使Xcode显示它们.有工具可以做到这一点,但除了退出并重新启动之外,没有办法让Xcode重新加载docset,所以我不建议打扰.
Xcode 5(目前作为OS X和iOS开发人员程序的付费成员的开发人员预览版提供)确实显示了您自己代码的文档注释; 请参阅" 开发人员工具功能"页面上的"快速帮助".您必须在头文件中编写doc注释.您可以使用doxygen或headerdoc格式.