Makaille Makaille - 1 year ago 75
iOS Question

How found and get value in an array

let firstArray =
[[name: "John", id: "001", active: "true"],
[name: "Paul", id: "002", active: "false"]]

let user: User? //This user contains information like an id (002)

hello there, i want to tell "look in the firstArray in each profil, and found the profil where the id is the same. In the example it's Paul. I want to get back the paul profil [name: "Paul", id: "002", active: "false"]

I hope this more clean now, thanks for feedback

Answer Source
for item in firstArray{
    let user_id=item.value(forKey: "id") as! String
    if user_id==some_id{
        print("found user")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download