iOS Swift 代表的文档?
iOS documentation for delegates in Swift?
我们应该如何记录 Swift 中的代表?如果我将我的文档放在协议中,class 将看起来是空的(文档方面),反之亦然。如果我把它放在两个地方,维护起来会很麻烦。
有什么方法可以 link 我们 classes 中的方法到记录的协议方法吗?
协议的代码文档示例:
protocol SomeDelegate: class {
/**
Awesome method
- parameters:
- oneParam: This works great
*/
func testAwesome(oneParam: Int)
}
在我的 class:
class AwesomeClass: SomeDelegate {
/// Should we just make a little note? Or what does apple expect?
func testAwesome(oneParam: Int) {
// implement stuff
}
}
编辑:
另见示例:
/// - Note: Implementation of Something, (note this works)
/// - SeeAlso: Test (note this does not show when holding alt)
func doneWithSomething() {
}
主要解释应该在协议上 class 以便将实施您的委托的开发人员知道将要实施什么。
在你的 class 文件中添加一些关于方法的解释,并在你的评论中使用 SeeAlso 标签命名协议 class
class AwesomeClass: SomeDelegate {
/*
Should we just make a little note? Or what does apple expect?
- SeeAlso: `SomeDelegate`
*/
func testAwesome(oneParam: Int) {
// implement stuff
}
}
我们应该如何记录 Swift 中的代表?如果我将我的文档放在协议中,class 将看起来是空的(文档方面),反之亦然。如果我把它放在两个地方,维护起来会很麻烦。
有什么方法可以 link 我们 classes 中的方法到记录的协议方法吗?
协议的代码文档示例:
protocol SomeDelegate: class {
/**
Awesome method
- parameters:
- oneParam: This works great
*/
func testAwesome(oneParam: Int)
}
在我的 class:
class AwesomeClass: SomeDelegate {
/// Should we just make a little note? Or what does apple expect?
func testAwesome(oneParam: Int) {
// implement stuff
}
}
编辑:
另见示例:
/// - Note: Implementation of Something, (note this works)
/// - SeeAlso: Test (note this does not show when holding alt)
func doneWithSomething() {
}
主要解释应该在协议上 class 以便将实施您的委托的开发人员知道将要实施什么。
在你的 class 文件中添加一些关于方法的解释,并在你的评论中使用 SeeAlso 标签命名协议 class
class AwesomeClass: SomeDelegate {
/*
Should we just make a little note? Or what does apple expect?
- SeeAlso: `SomeDelegate`
*/
func testAwesome(oneParam: Int) {
// implement stuff
}
}