gamekit - Whats the correct signature of receiveData:fromPeer:inSession:context: in swift? -


im trying rewrite gamekit multiplayer game (local) in swift , have problems missing documentation language. want receive data peer set datareceivehandler gksession this:

session.setdatareceivehandler(self, withcontext: nil) 

in apples documentation says datareceivehandler hast implement method signature:

sel = -receivedata:frompeer:insession:context: 

in objective-c documentation example of how signature should like:

- (void) receivedata:(nsdata *)data frompeer:(nsstring *)peer insession: (gksession *)session context:(void *)context; 

if try rewrite method in swift looks this:

func receivedata(data: nsdata, frompeer peer: string, insession session: gksession, withcontext context: cmutablevoidpointer) {     println("received data: \(data)") } 

and gives me error when receive message:

domain=com.apple.gamekit.gksessionerrordomain code=30500 "invalid parameter -setdatareceivehandler:withcontext:" userinfo=0x178462840 {nslocalizeddescription=invalid parameter -setdatareceivehandler:withcontext:, nslocalizedfailurereason=the handler not respond correct selector.}

this means method has not correct signature. correct one?

it's problem renaming parameters. wrote withcontext context instead of context withcontext. first name 1 exposed callers.

this should work:

func receivedata(data: nsdata, frompeer peer: string, insession session: gksession, context: cmutablevoidpointer) {     println("received data: \(data)") } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -