There are items that are based on an order in JSON that need to be returned in that specific order if their bool is true:
"items": {
"item1": true,
"item2": true,
"item3": true,
"item4": true,
"item5": true,
"item6": true
}
These items then need to show their corresponding images in order in a collectionview. Is there a way after adding these items to an array to get those itmes in the correct order?
This is the function I'm using now,it works but the order is different:
var appMenuJSON: NSDictionary?
var menuButtonsArray: [String?] = []
func getItems(){
guard let items = appMenuJSON else {return}
for (key, value) in items {
if let val = value as? Bool, val == true {
menuButtonsArray.append(key as! String)
}
}