Don't use NSDictionary

This commit is contained in:
Erik Little 2017-09-17 11:31:24 -04:00
parent 654d71abed
commit 02d82adf07
No known key found for this signature in database
GPG Key ID: 4930B7C5FBC1A69D
2 changed files with 4 additions and 4 deletions

View File

@ -206,7 +206,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
private func checkAndHandleEngineError(_ msg: String) {
do {
let dict = try msg.toNSDictionary()
let dict = try msg.toDictionary()
guard let error = dict["message"] as? String else { return }
/*
@ -435,7 +435,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
}
private func handleOpen(openData: String) {
guard let json = try? openData.toNSDictionary() else {
guard let json = try? openData.toDictionary() else {
didError(reason: "Error parsing open packet")
return

View File

@ -111,9 +111,9 @@ extension String {
return array
}
func toNSDictionary() throws -> NSDictionary {
func toDictionary() throws -> [String: Any] {
guard let binData = data(using: .utf16, allowLossyConversion: false) else { return [:] }
guard let json = try JSONSerialization.jsonObject(with: binData, options: .allowFragments) as? NSDictionary else {
guard let json = try JSONSerialization.jsonObject(with: binData, options: .allowFragments) as? [String: Any] else {
throw JSONError.notNSDictionary
}