Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.69 KB | None | 0 0
  1. func getEquipmentHistory(for group: [String]) -> [Equipment] {
  2.         if self.historyList.count > 0 {
  3.             let historyList = self.historyList.filter({group.contains($0.equipment.group1)})
  4.             let sorted = historyList.sorted(by: { (aData, bData) -> Bool in
  5.                 aData.dateAdded > bData.dateAdded
  6.             })
  7.             var list : [Equipment] = []
  8.             for item in sorted {
  9.                 list.append(item.equipment)
  10.             }
  11.            
  12.             let cut_down : ArraySlice<Equipment> = list.prefix(HISTORY_LIMIT)
  13.             self.currentHistoryList = Array(cut_down)
  14.             return self.currentHistoryList
  15.         }
  16.         return []
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement