How to get userid using for loop from the Anyhashable type of data?
//This is the data and I want to get all of the userid from this data
? some : 6 elements
? 0 : 2 elements
? key : AnyHashable("company_name")
- value : "company_name"
- value : Company 2549
? 1 : 2 elements
? key : AnyHashable("contact_unique_id")
- value : "contact_unique_id"
- value : 230679
? 2 : 2 elements
? key : AnyHashable("Client_Phone")
- value : "Client_Phone"
- value : 999999
? 3 : 2 elements
? key : AnyHashable("userid")
- value : "userid"
- value : 7295
? 4 : 2 elements
? key : AnyHashable("full_name")
- value : "full_name"
- value : A. B. M
? 5 : 2 elements
? key : AnyHashable("email_address")
- value : "email_address"
- value : wwsum.mar.com
if Utils.getSharedManagerObject().arraySelectContacts.count > 0 {
let contactDictionary = Utils.getSharedManagerObject().arraySelectContacts[0] as? [AnyHashable : Any]
let contactName = contactDictionary!["full_name"] as! String
let toBeDisplayedText = Utils.getSharedManagerObject().arraySelectContacts.count > 1 ? "(contactName) + (Utils.getSharedManagerObject().arraySelectContacts.count - 1) more" : contactName self.btnSelectContact.setTitle(toBeDisplayedText , for: UIControlState.normal)
self.btnSelectContact.setTitleColor(UIColor.black , for: UIControlState.normal)
}
else {
self.btnSelectContact.setTitle("Tap to Select Contact(s)", for: UIControlState.normal)
self.btnSelectContact.setTitleColor(UIColor.gray , for: UIControlState.normal)
}
if Utils.getSharedManagerObject().arraySelectAssignees.count > 0 {
let contactDictionary = Utils.getSharedManagerObject().arraySelectAssignees[0] as? [AnyHashable : Any]
//I am try to get userid from this code
let contactName = contactDictionary!["full_name"] as! String
if let users = contactDictionary as? [String : Any] {
print(users)
for user in users {
print(user)
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…