var matchmakingIds: [Int] = [] for categoryDictionary in categoryDictionaries { if let title = categoryDictionary["title"] as? String, title == "Matchmaking"{ guard let children = categoryDictionary["children"] as? [NSDictionary] else { print("Cannot find key 'children' in \(categoryDictionary)") return } for child in children { guard let categoryId = child["categoryId"] as? Int else { print("Cannot find key 'categoryId' in \(child)") return } matchmakingIds.append(categoryId) } } }