[Solved] Alert view with JSON data [closed]


Don’t use NSDictionary in swift. Use [String:Any]. Get all values of the dictionary and join the array of strings. And join the error with a new line as a separator.

let jsonObj:[String: Any] = ["error": [
                "email": ["The email has already been taken."],
                "phone": ["The phone has already been taken."]]
                ]
if let errorMsgs = jsonObj["error"] as? [String: [String]] {
    let errMsg = errorMsgs.values.map { $0.reduce("", +) }.joined(separator: "\n")
    print(errMsg)
    createAlert(title: "Try again" , message: errMsg)
}

enter image description here

2

solved Alert view with JSON data [closed]