I have a list of items that contains groups, when I print them, it shows all groups.
MOVIE: Cartoon Multi Subtitles
MOVIE: Cartoon Multi Subtitles
MOVIE: Cartoon Multi Subtitles
MOVIE: Cartoon Multi Subtitles
MOVIE: Cartoon Multi Subtitles
MOVIE: English
MOVIE: English
MOVIE: English
MOVIE: English
MOVIE: English
I found that using Set will remove duplicates.
@IBAction func button(_ sender: Any) {
let alertController = UIAlertController(title: "", message: "", preferredStyle: .alert)
let uniqueGroups = Set((playlist?.objects.map({ $0.group }))!)
alertController.addAction(UIAlertAction(title: uniqueGroups, style: .default) { <-- Cannot convert value of type 'Set<String>' to expected argument type 'String?'
action in
})
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel))
self.present(alertController, animated: true, completion: nil)
}
Cannot convert value of type 'Set<String>' to expected argument type 'String?'