Don't use NSDictionary in definitions

This commit is contained in:
Erik Little 2017-10-22 10:26:16 -04:00
parent 846e7cb0aa
commit cf597ae09d
No known key found for this signature in database
GPG Key ID: 4930B7C5FBC1A69D
6 changed files with 14 additions and 7 deletions

View File

@ -163,7 +163,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
/// - parameter client: The client for this engine.
/// - parameter url: The url for this engine.
/// - parameter options: The options for this engine.
public convenience init(client: SocketEngineClient, url: URL, options: NSDictionary?) {
public convenience init(client: SocketEngineClient, url: URL, options: [String: Any]?) {
self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? [])
}

View File

@ -90,7 +90,7 @@ import Starscream
/// - parameter client: The client for this engine.
/// - parameter url: The url for this engine.
/// - parameter options: The options for this engine.
init(client: SocketEngineClient, url: URL, options: NSDictionary?)
init(client: SocketEngineClient, url: URL, options: [String: Any]?)
/// Starts the connection to the server.
func connect()

View File

@ -150,8 +150,8 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
/// - parameter socketURL: The url of the socket.io server.
/// - parameter config: The config for this socket.
@objc
public convenience init(socketURL: NSURL, config: NSDictionary?) {
self.init(socketURL: socketURL as URL, config: config?.toSocketConfiguration() ?? [])
public convenience init(socketURL: URL, config: [String: Any]?) {
self.init(socketURL: socketURL, config: config?.toSocketConfiguration() ?? [])
}
deinit {

View File

@ -42,7 +42,7 @@ extension CharacterSet {
}
}
extension NSDictionary {
extension Dictionary where Key == String, Value == Any {
private static func keyValueToSocketIOClientOption(key: String, value: Any) -> SocketIOClientOption? {
switch (key, value) {
case let ("connectParams", params as [String: Any]):
@ -90,7 +90,7 @@ extension NSDictionary {
var options = [] as SocketIOClientConfiguration
for (rawKey, value) in self {
if let key = rawKey as? String, let opt = NSDictionary.keyValueToSocketIOClientOption(key: key, value: value) {
if let opt = Dictionary.keyValueToSocketIOClientOption(key: rawKey, value: value) {
options.insert(opt)
}
}

View File

@ -463,7 +463,7 @@ class TestEngine : SocketEngineSpec {
private(set) var websocket = false
private(set) var ws: WebSocket? = nil
required init(client: SocketEngineClient, url: URL, options: NSDictionary?) {
required init(client: SocketEngineClient, url: URL, options: [String: Any]?) {
self.client = client
}

View File

@ -11,6 +11,13 @@
@implementation ManagerObjectiveCTest
- (void)testSettingConfig {
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"];
self.manager = [[TestManager alloc] initWithSocketURL:url config:@{@"forceNew": @YES}];
XCTAssertTrue(self.manager.forceNew);
}
- (void)testManagerProperties {
XCTAssertNotNil(self.manager.defaultSocket);
XCTAssertNil(self.manager.engine);