Reputation: 1
I'm new to development in objective-c / swift:
I'm trying to connect to a socket.io server by using the api (https://github.com/MegaBits/SIOSocket)
i've imported it via cocoapods and bridging header into my project.
the completion of xcode look like this:
var io: SIOSocket = SIOSocket.socketWithHost
(hostURL: String!>, response: ((SIOSocket!) -> Void)!(SIOSocket!) -> Void)
I don't know what to fill in as "response" !
the original declaration is:
+ (void)socketWithHost:(NSString *)hostURL
response:(void(^)(SIOSocket *socket))response;
Upvotes: 0
Views: 903
Reputation: 93296
I think the autocomplete code got a little messed up. That second parameter is a closure -- this should be the code you can use to create the socket (using a trailing closure):
SIOSocket.socketWithHost("http://example.com") {
(socket: SIOSocket!) -> Void in
self.socket = socket
// any other response handling here
}
Note - this is an asynchronous method, so you can't directly assign the result. You'll need to have a socket
property in your class that gets set via this method.
Upvotes: 2