amandeepsingh amandeepsingh - 6 months ago 70
iOS Question

Injecting parameter in Typhoon Swift

I am using the following code to inject a enum parameter in Typhoon in Swift:

public dynamic func introPageViewController() -> AnyObject {
return TyphoonDefinition.withClass(UIPageViewController.self) {
(definition) in

(initializer) in



The problem is that injectParameterWith method only accepts parameters of type AnyObject and the parameter I want to inject is of Int type so this code gives a compiler error.
How would I achieve this without causing any compiler error or crash?


As outlined in the Typhoon User Guide here, to inject an enum it is necessary to box it as an NSNumber. I'm actually not sure how to box explicitly in Swift but you could do it with something like:

var num: NSNumber = mode.rawValue