Q:

How to find a value in array of dictionaries

I have array of dictionaries:
let someArray = [["Andrew":"qwerty"],["Paul":"123456"],["Sarah":"123123"]]

And I have a value which I want to find in array
let search = "Sarah"

I want to know if value "Sarah" exists in the array. How can I do that ? 

A:

You have an array of dictionaries. 
You just need to search the dictionary having a key == "Sarah" so
let elms = [["Andrew":"qwerty"],["Paul":"123456"],["Sarah":"123123"]]

let sarahDict = elms.first { $0.keys.contains("Sarah") }

Model Value
However a Model Value would make the code much more clear
let elms = [["Andrew":"qwerty"],["Paul":"123456"],["Sarah":"123123"]]

struct Person {

    let name: String
    let value: String

    init?(dict:[String:String]) {
        guard let name = dict.keys.first, let value = dict[name] else { return nil }
        self.name = name
        self.value = value
    }
}

let person = elms.compactMap(Person.init).first { $0.name == "Sarah" } 

