Hi,
I use a predicate to filter a NSTableView when I type in a NSSearchField :
private func _filterTracks(str: String) {
var thePredicates = [NSPredicate]()
let theArtistPredicate = NSPredicate(format: FilterType.format, FilterType.artistField, str)
let theTitlePredicate = NSPredicate(format: FilterType.format, FilterType.titleField, str)
let theAlbumPredicate = NSPredicate(format: FilterType.format, FilterType.albumField, str)
switch _filter?.tag {
case FilterType.FilterListType.ALL.rawValue:
thePredicates.append(theArtistPredicate)
thePredicates.append(theTitlePredicate)
thePredicates.append(theAlbumPredicate)
case FilterType.FilterListType.artist.rawValue:
thePredicates.append(theArtistPredicate)
case FilterType.FilterListType.album.rawValue:
thePredicates.append(theAlbumPredicate)
case FilterType.FilterListType.title.rawValue:
thePredicates.append(theTitlePredicate)
default:
thePredicates.append(theArtistPredicate)
thePredicates.append(theTitlePredicate)
thePredicates.append(theAlbumPredicate)
}
let theCompoundPredicate = NSCompoundPredicate(type: NSCompoundPredicate.LogicalType.or, subpredicates: thePredicates)
arrayController.filterPredicate = theCompoundPredicate
}
But when the NSSearchField is reset, how to reset the filter and get the datas in the NSTableView like it was ?
Thx.