enum DateFormat{
case ShortDateFormat //7/28/2014 ShortStyle
case LongDateFormat //July 28, 2014 LongStyle
case LongFormatWithDay //Monday, July 28, 2014 FullStyle
case CurrentDayThreeLetters //Mon
}
HeaderDoc 标签适用于 Objective-C 和 Swift,尽管在 Swift 中,格式略有不同。在 Objective - C 中,记录方法的正确格式是这样的:
/*!
* @discussion This is an example discussion.
* @param bar - This is an example of a parameter.
* @return An example for a return type
*/
-(id)foo:(bar)foobar;
alt-click foo: 的结果是这样的
在 swift 中,文档的方式有点不同:
/**
This is an example discussion
:param: bar This is an example parameter.
:returns: This is an example return type.
*/
func foo(foobar: AnyObject) -> AnyObject {...}
这给出了与上面的 alt-clicking 相同的例子。
对于枚举,其原理与上面使用/** */ 格式的相同,但也使用/// 来描述单个枚举。
/**
Example enum description
- First: First example
- Second: Second example
- Third: Third example
- Fourth: Fourth example
*/
enum Example {
///First example
case First
///Second example
case Second
///Third example
case Third
///Fourth example
case Fourth
}