Thursday 15 September 2011

swift - AnyObject is not a subtype of SIOParameterArray -



swift - AnyObject is not a subtype of SIOParameterArray -

i utilize siosocket connect nodejs ,this code

siosocket.socketwithhost("xxxxxxxxxx", response: { (socket:siosocket!) in

self.socket = socket; self.socket.on("move", callback: { (args:sioparameterarray) in println("aaa") })

})

but there error in line

self.socket.on("move", callback: { (args:sioparameterarray) in '[anyobject]!' not subtype of 'sioparameterarray'

sioparameterarray alias of nsarray. so, objective-c definition:

typedef nsarray sioparameterarray @interface siosocket : nsobject - (void)on:(nsstring *)event callback:(void (^)(sioparameterarray *args))function; @end

is identical to:

@interface siosocket : nsobject - (void)on:(nsstring *)event callback:(void (^)(nsarray *args))function; @end

and it's translated swift as:

class siosocket : nsobject { func on(event: string!, callback function: (([anyobject]!) -> void)!) }

so, can utilize [anyobject]! compiler says:

siosocket.socketwithhost("xxxxxxxxxx", response: { (socket:siosocket!) in self.socket = socket; self.socket.on("move", callback: { (args:[anyobject]!) in println("aaa") }) })

swift

No comments:

Post a Comment