Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 用空函数复制函数以获得广泛的内联文档_Ios_Swift_Xcode_Uiviewcontroller - Fatal编程技术网

Ios 用空函数复制函数以获得广泛的内联文档

Ios 用空函数复制函数以获得广泛的内联文档,ios,swift,xcode,uiviewcontroller,Ios,Swift,Xcode,Uiviewcontroller,我试图通过在不同文件中使用“blank”函数向接口函数添加内联文档来复制Java的接口文档样式 以下是我想要的: 视图控制器 class ViewController: UIViewController { func myFunction(_ message: String) { // Code here... } } 扩展名ViewController(与我的所有文档分开) 到目前为止,我一直在处理这样的文件: 如果我理解正确,您希望将函数的定义(及其文档

我试图通过在不同文件中使用“blank”函数向接口函数添加内联文档来复制Java的接口文档样式

以下是我想要的:

视图控制器

class ViewController: UIViewController {

    func myFunction(_ message: String) {
        // Code here...
    }

}
扩展名ViewController(与我的所有文档分开)

到目前为止,我一直在处理这样的文件:


如果我理解正确,您希望将函数的定义(及其文档)与实际实现分开。您的路径基本上是正确的,但不是定义一个协议,而不是
extension ViewController
,该协议要求一致性类型为
UIViewController

protocol MyViewController: UIViewController {

    /**
      A very
      very, very,
      very, long
      inline documentation
    */
    func myFunction(_ message: String)

}
然后

class ViewController: UIViewController, MyViewController {

    func myFunction(_ message: String) {
        // Code here...
    }

}

在iOS上,接口=协议,问题是什么?如果你需要为一个方法编写太多的文档,那么这个方法可能太复杂,应该重构成几个方法
class ViewController: UIViewController, MyViewController {

    func myFunction(_ message: String) {
        // Code here...
    }

}