From 90187aa4585ed55d277e2432f645c745c79061d5 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 16 Mar 2015 11:47:42 -0400 Subject: [PATCH] fix convenience constructor. Bump version --- README.md | 10 ++++++---- Socket.IO-Client-Swift.podspec | 4 ++-- SwiftIO/SocketIOClient.swift | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d197693..baa81ce 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,11 @@ import Socket_IO_Client_Swift API === -Constructor +Constructors ----------- -`init(socketURL: String, opts:[String: AnyObject]? = nil)` - Constructs a new client for the given URL. opts can be omitted (will use default values. See example) +`init(socketURL: String, opts:NSDictionary? = nil)` - Constructs a new client for the given URL. opts can be omitted (will use default values. See example) + +`convenience init(socketURL: String, options:NSDictionary? = nil)` - Same as above, but meant for Objective-C. See Objective-C Example. Methods ------- 1. `socket.on(name:String, callback:((data:NSArray?, ack:AckEmitter?) -> Void))` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example. @@ -124,12 +126,12 @@ socket.connect() Objective-C Example =================== ```objective-c -SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" opts:nil]; +SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil]; [socket on: @"connect" callback: ^(NSArray* data, void (^ack)(NSArray*)) { NSLog(@"connected"); [socket emitObjc:@"echo" :@[@"echo test"]]; - [[socket emitWithAckObjc:@"ackack" :@[@"test"]] onAck:^(NSArray* data) { + [[socket emitWithAckObjc:@"ackack" :@[@"test"]] onAck:0 withCallback:^(NSArray* data) { NSLog(@"Got data"); }]; }]; diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index e689e1a..7024656 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" - s.version = "1.1.4" + s.version = "1.1.5" s.summary = "Socket.IO-client for Swift" s.description = <<-DESC Socket.IO-client for Swift. @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.author = { "Erik" => "nuclear.ace@gmail.com" } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' - s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.1.4' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.1.5' } s.source_files = "SwiftIO/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files diff --git a/SwiftIO/SocketIOClient.swift b/SwiftIO/SocketIOClient.swift index b43a944..330ffbf 100644 --- a/SwiftIO/SocketIOClient.swift +++ b/SwiftIO/SocketIOClient.swift @@ -74,7 +74,7 @@ public class SocketIOClient: NSObject { return self._sid } - public init(var socketURL:String, opts:[String: AnyObject]? = nil) { + public init(var socketURL:String, opts:NSDictionary? = nil) { if socketURL["https://"].matches().count != 0 { self._secure = true } @@ -116,8 +116,8 @@ public class SocketIOClient: NSObject { self.engine = SocketEngine(client: self, forcePolling: self.forcePolling) } - public convenience init(socketURL:String, opts:NSDictionary?) { - self.init(socketURL: socketURL, opts: opts) + public convenience init(socketURL:String, options:NSDictionary?) { + self.init(socketURL: socketURL, opts: options) } // Closes the socket