xcode报错declaration is only at file scope

39 阅读1分钟

在Xcode中用swift的时候,写一个代理方法的时候,报错:

declaration is only at file scope

仔细看了一下,是因为:

class ViewController: UIViewController {

// 在这里写代理方法会报错

}

// 得在这里写代理方法才可以