且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iOS swift中使用完成处理程序正确记录方法

更新时间:2023-02-02 09:30:27

  / ** 
发送一个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/