我可以在多个 UIViewController 中重用一个变量,方法是将它存储在我项目中的一个单独的 Swift 文件中,但我似乎无法对函数执行相同的操作。它根本不像变量那样被识别。
我该怎么做?
最佳答案
你必须在类体之外声明它:
import UIKit
import SpriteKit
class OneClass{
func notGlobal(){
println("not global")
}
func globalMethod(string:String){
println("its global")
}
关于ios - 跨多个 UIViewControllers 重用一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28178203/