小编Ale*_* G.的帖子

不允许部分应用协议方法

有人可以解释这个错误,为什么这适用于关闭?

如果你在'B'类中将'Test'更改为'A',那么在这两种情况下一切都有效.

beta 7

protocol Test {
    func someFunc() -> String
    var someClosure: () -> Int { get }
}

class A: Test {
    func someFunc() -> String {
        return "A String"
    }

    var someClosure: () -> Int {
        return {
            return 2
        }
    }
}

class B {
    let a: Test
    let aString: () -> String
    let aInt: () -> Int

    init(a: Test){
        self.a = a

        aString = a.someFunc // Error: Partial application of protocol method is not allowed …
Run Code Online (Sandbox Code Playgroud)

methods closures protocols swift xcode6-beta7

8
推荐指数
2
解决办法
2110
查看次数

标签 统计

closures ×1

methods ×1

protocols ×1

swift ×1

xcode6-beta7 ×1