如何在iOS swift中使用完成处理程序正确记录方法 [英] How can I properly document a method with a completion handler in iOS swift
本文介绍了如何在iOS swift中使用完成处理程序正确记录方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
/ **
描述
- 参数:
- 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屋!
查看全文