0

プロトコルにアクセスする必要がありますが、次のエラーが表示されます:

'MyProtocol' cannot be constructed because it has no accessible initializers

これが私の実装です:

public protocol MyProtocol{
    var someVar: Int {set get}
    var anotherVar: String {set get}
}


class ProtocolProjectTests: XCTestCase {
    var myProtocol: MyProtocol!

    override func setUp() {
        self.myProtocol = MyProtocol()
    }
}

この行self.myProtocol = MyProtocol()で、エラーが発生しています。

皆さんへの私の質問は、XCTest クラスで変数を初期化する方法です。

本当にありがとうございました。

4

1 に答える 1