In my app I'm presenting to the user the contents of their iTunes library. Each track is represented by a custom object in an array, controlled by an NSArrayController, which is displayed in an NSTableView.
In my first implementation of searching I'm binding the predicate binding of an NSSearchField to my array controller, with this predicate format:
(name contains[cd] $value) OR (album contains[cd] $value) OR (albumArtist contains[cd] $value) OR (artist contains[cd] $value) OR (composer contains[cd] $value) OR (genre contains[cd] $value)
I'm chuffed (to say the least!) with how well this works, considering it requires no code at all. However, it isn't quite as flexible as iTunes' search. iTunes seems to break up the search query and perform it word by word, matching each word in any of the track's properties. For example, if you type "jackson bad" into the search field, you will get the song "Bad" by the artist "Michael Jackson".
I can't work out how to do this with my predicate binding, since $value represents the entire search string and there seems to be no way to break it down. Is my only option to perform the searching manually in code? This would seem to be a waste of a good binding!
In my first implementation of searching I'm binding the predicate binding of an NSSearchField to my array controller, with this predicate format:
(name contains[cd] $value) OR (album contains[cd] $value) OR (albumArtist contains[cd] $value) OR (artist contains[cd] $value) OR (composer contains[cd] $value) OR (genre contains[cd] $value)
I'm chuffed (to say the least!) with how well this works, considering it requires no code at all. However, it isn't quite as flexible as iTunes' search. iTunes seems to break up the search query and perform it word by word, matching each word in any of the track's properties. For example, if you type "jackson bad" into the search field, you will get the song "Bad" by the artist "Michael Jackson".
I can't work out how to do this with my predicate binding, since $value represents the entire search string and there seems to be no way to break it down. Is my only option to perform the searching manually in code? This would seem to be a waste of a good binding!