如何在iOS swift中使用完成处理程序正确记录方法 [英] How can I properly document a method with a completion handler in iOS swift

查看:165
本文介绍了如何在iOS swift中使用完成处理程序正确记录方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在记录我公司的iOS应用程序的代码,现在我已经转到了有完成处理程序的方法。有没有具体的记录完成处理程序的方法,还是应该把它作为参数的一部分?



例如:

  / ** 
描述
- 参数:
- parameter1:description
- parameter2:description
- 完成:描述
* /

这是正确的方法还是还有更好的方法?或者也许应该在文档的返回部分?



谢谢

解决方案

  / ** 
发送一个API请求到4sq为一个给定的位置周围的场所与一个可选的文本搜索

:param:location一个用户当前位置的CLL位置
:param:查询可选的搜索查询
:param:completion一个与场馆调用的关闭,一个FoursquareVenue对象的数组

:返回:无返回值
* /
func requestVenues(位置:CLLocation,查询:String?,完成:(场馆:[FoursquareVenue]?) - > Void){...}

取自 https://thatthinginswift.com/documentation-and-快速帮助/


I'm documenting the code for my company's iOS application, and now I've moved on to methods that have a completion handler. Is there a specific method for documenting completion handlers, or should I just put it as part of the parameters?

for example:

/**
Description
- Parameters:
     - parameter1: description
     - parameter2: description
     - completion: description
*/

Is this the right way or is there another better way? Or maybe it should be in the "Returns" part of the documentation?

Thanks

解决方案

/**
Sends an API request to 4sq for venues around a given location with an optional text search

:param: location    A CLLocation for the user's current location
:param: query       An optional search query
:param: completion  A closure which is called with venues, an array of FoursquareVenue objects

:returns: No return value
*/
func requestVenues(location: CLLocation, query: String?, completion: (venues: [FoursquareVenue]?) -> Void) { … }

taken from https://thatthinginswift.com/documentation-and-quick-help/

这篇关于如何在iOS swift中使用完成处理程序正确记录方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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