I have a list in my VC
var list : [QCategoryy] = [QCategoryy]()
list = NearbyPlaces.getCategories()
list.shuffled()
where getCategories()
is the func
static func getCategories() -> [QCategoryy] {
let list:[QCategoryy] = [QCategoryy(name: "bar", image: UIImage(named: "bar_button.png")!), QCategoryy(name :"night_club", image: UIImage(named: "nightclub_button.png")!), QCategoryy(name: "movie_theater", image: UIImage(named: "cinema_button.png")!), QCategoryy(name: "restaurant", image: UIImage(named: "restaurant_button.png")!), QCategoryy(name: "gym", image: UIImage(named: "gym_button.png")!), QCategoryy(name: "spa", image: UIImage(named: "spa_button.png")!), QCategoryy(name: "museum", image: UIImage(named: "museum_button.png")!)]
return list
}
what i would like to do is to take a randomly number of items from this list and add them to another list like var filteredList = [QCategoryy]()
, how can i do?
UPDATE
i would like to do it when the user tap a button