我想傳遞一個委託的背景下,並試圖做這樣的事情:如何傳遞一個函數作爲上下文參數?
func process(value: Float) -> Float {
return value * 999.9
}
-----------
self.pushControllerWithName("someController", context: [
"func": SomeUtils.process,
"someValue": 1
])
在someController
,我試圖做這樣的事情在init:
var contextFunc = context as func
contextFunc(123)
這是行不通的:'AnyObject?' does not have a member named 'Key'
這個錯誤來自pushContollerWithName線? – 2015-04-05 16:12:37
是的,與「func」鍵一致。 – TruMan1 2015-04-05 16:13:20
您可以發佈方法pushControllerWithName()的簽名嗎? – Abdullah 2015-04-05 16:14:43