[ad_1]
I must solid the under response from my server as [UserResult] however I can’t get it to work??
What am I doing mistaken?
func userSearch(key phrase: String, completion: @escaping (End result<[UserResult], ResponseError>) -> Void ) {
socket.emit("userSearch", key phrase)
socket.on("userFound") { ( information, ack) in
print(information) // prints under NSArray
if !information.isEmpty {
if let response = information as? [UserResult] {
print("USERS (response)") // WILL NOT WORK?
completion(.success(response))
}
} else {
completion(.failure(.badRequest("No customers discovered")))
}
}
}
Information from server
[<__NSArrayM 0x60000040e5b0>(
{
profileUrl = "www.address1.com";
username = chrissmith;
},
{
profileUrl = "www.address2.com";
username = johnsmith;
},
{
profileUrl = "www.address3.com";
username = alicesmith;
}
)
]
UserResult Mannequin
struct UserResult: Decodable {
let username: String
let profileUrl: String
}
[ad_2]
