iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – Xcode 6中的文档方法和枚举大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Does Swift have documentation generation support?                                    11个
我在Swift中有一个枚举:

enum DateFormat{
   case ShortDateFormat //7/28/2014 ShortStyle
   case LongDateFormat  //July 28,2014 LongStyle
   case LongFormatWithDay //Monday,July 28,2014 FullStyle
   case CurrentDayThreeLetters //Mon
 }

我希望这个记录类似于intellisense在C#中的工作方式,在我输入DateFormat.ShortDateFormat的那一刻,弹出窗口会告诉我这会产生7/28/2014.

我还想用我写的那些难以记忆的函数来做这件事,这些函数返回特定的东西以使我更容易,所以我不必回到文件并查看它究竟做了什么(不是我有这些功能很多,请注意)!

我怎么能做这样的事情?

解决方法

@H_801_19@ 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单击时,这会给出相同的示例.

对于枚举,其原理与上面使用/ ** * /格式相同,但也使用///作为单独的枚举描述.

/**
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
}

结果是一个整齐的格式,项目符号列表:

当alt-click其中一个实际案例时:.

您将使用自动完成功能获得所需的效果,如下所示:

大佬总结

以上是大佬教程为你收集整理的ios – Xcode 6中的文档方法和枚举全部内容,希望文章能够帮你解决ios – Xcode 6中的文档方法和枚举所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。