swift类声明里面的方法无法达到方法?

时间:2014-11-16 21:00:28

标签: swift

我正在使用XCTest并在TestMethod中声明类作为模拟类的一种方法。但是,似乎该类无法在其声明之外调用方法。我该如何解决这个问题?

class MyTestCase : XCTestCase {
    func testExample() {
        class Bar {  // <-- the class declared inside a function
            func Barkly() {
                 foo(); // <-- apparently this produces a compile error.
            }
        }
    }

    func foo() { //<-- this is the method I am trying to call
        println("hello world")
    }
}

0 个答案:

没有答案