【发布时间】:2015-04-05 10:12:33
【问题描述】:
我正在尝试获取对这样一个函数的引用:
class Toto {
func toto() { println("f1") }
func toto(aString: String) { println("f2") }
}
var aToto: Toto = Toto()
var f1 = aToto.dynamicType.toto
我有以下错误:Ambiguous use of toto
如何获取指定参数的函数?
【问题讨论】:
-
请注意,
aToto.dynamicType.toto返回一个以类实例作为其第一个参数的柯里化函数,因为您通过其类型 (aToto.dynamicType) 引用它。aToto.toto的等价物是Toto.toto(aToto)或aToto.dynamicType.toto(aToto)
标签: objective-c function swift dynamictype