Don't use NSDictionary
This commit is contained in:
parent
c20c286864
commit
1faa4b925c
@ -216,7 +216,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 }
|
||||
|
||||
/*
|
||||
@ -419,7 +419,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
|
||||
|
||||
@ -114,9 +114,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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user