diff --git a/README.md b/README.md index 60ba181..e9f3ea3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Socket.IO-client for iOS/OS X. ##Example ```swift -let socket = SocketIOClient(socketURL: "localhost:8080", opts: [.Log(true), .ForcePolling(true)]) +let socket = SocketIOClient(socketURL: "localhost:8080", options: [.Log(true), .ForcePolling(true)]) socket.on("connect") {data, ack in print("socket connected") @@ -26,7 +26,7 @@ socket.connect() ##Objective-C Example ```objective-c -SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" opts:@{@"log": @YES, @"forcePolling": @YES}]; +SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:@{@"log": @YES, @"forcePolling": @YES}]; [socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) { NSLog(@"socket connected"); @@ -120,8 +120,8 @@ Run `seed install`. ##API Constructors ----------- -`init(var socketURL: String, opts: SocketOptionsSet? = nil)` - Creates a new SocketIOClient. opts is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL. -`convenience init(socketURL: String, opts: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys. +`init(var socketURL: String, options: SocketOptionsSet? = nil)` - Creates a new SocketIOClient. opts is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL. +`convenience init(socketURL: String, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys. Options ------- diff --git a/SocketIOClientSwift/SocketIOClient.swift b/SocketIOClientSwift/SocketIOClient.swift index 4a08b63..2a9cf7d 100644 --- a/SocketIOClientSwift/SocketIOClient.swift +++ b/SocketIOClientSwift/SocketIOClient.swift @@ -32,7 +32,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient { public private(set) var status = SocketIOClientStatus.NotConnected public var nsp = "/" - public var opts: SocketOptionsSet? + public var options: SocketOptionsSet? public var reconnects = true public var reconnectWait = 10 public var sid: String? { @@ -57,7 +57,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient { /** Type safe way to create a new SocketIOClient. opts can be omitted */ - public init(var socketURL: String, opts: SocketOptionsSet? = nil) { + public init(var socketURL: String, options: SocketOptionsSet? = nil) { if socketURL["https://"].matches().count != 0 { self.secure = true } @@ -66,9 +66,9 @@ public final class SocketIOClient: NSObject, SocketEngineClient { socketURL = socketURL["https://"] ~= "" self.socketURL = socketURL - self.opts = opts + self.options = options - for option in opts ?? [] { + for option in options ?? [] { switch option { case .ConnectParams(let params): connectParams = params @@ -98,9 +98,9 @@ public final class SocketIOClient: NSObject, SocketEngineClient { Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity. If using Swift it's recommended to use `init(var socketURL: String, opts: SocketOptionsDictionary? = nil)` */ - public convenience init(socketURL: String, opts: NSDictionary?) { + public convenience init(socketURL: String, options: NSDictionary?) { self.init(socketURL: socketURL, - opts: SocketIOClientOption.NSDictionaryToSocketOptionsSet(opts ?? [:])) + options: SocketIOClientOption.NSDictionaryToSocketOptionsSet(options ?? [:])) } deinit { @@ -111,7 +111,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient { Logger.log("Adding engine", type: logType) let newEngine = SocketEngine(client: self, opts: - SocketIOClientOption.SocketOptionsSetToNSDictionary(opts ?? [])) + SocketIOClientOption.SocketOptionsSetToNSDictionary(options ?? [])) engine = newEngine return newEngine