How to set a default filter on an NSTableView so that no data is displayed if NSSearchField is empty?
How to set a default filter on an NSTableView so that no data is displayed if NSSearchField is empty?
- Subject: How to set a default filter on an NSTableView so that no data is displayed if NSSearchField is empty?
- From: Peter <email@hidden>
- Date: Sun, 08 Jul 2012 01:18:22 +0200
Hi,
is there an elegant/easy way to achieve this?
The scenario:
Target 10.5 on OS 10.6 (10.5 may be given up in the future).
Cell based table view bound to core data.
Controller set to prepares content, so all the data is loaded.
On entering a string into an NSSearchField the data is filtered.
This is pretty default and works.
What I want to see:
The table view comes up empty.
On entering a string, the table view displays the filtered data.
I clear the string and the table view goes blank again.
How could I achieve this?
I guess I could check for an empty string in controlTextDidChange: and set a predicate which is tailored not to find any matches, but somehow I'd rather find a way to execute a precise fetch using the NSSearchField instead of unnecessarily loading a lot of bloat into memory and only to narrow that down again for display.
At least this is how I assume the standard controller filter bindings work - or does the filtering really execute a fetch on core data behind the scenes? If the latter is the case it would eventually suffice to prevent data from being displayed for empty filter values.
Any insights?
Has anybody done something like this?
Any pointers are appreciated!
Thanks!
Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden