NSPredicate & live filtering question
NSPredicate & live filtering question
- Subject: NSPredicate & live filtering question
- From: Shamyl Zakariya <email@hidden>
- Date: Fri, 13 Mar 2009 08:49:50 -0400
Hi,
I'm belatedly dipping my toes into NSPredicate to do some array
filtering. I have an array of objects which have (among other things)
a boolean property. In my UI, I have three tables:
1) The first table has all the entries in the array.
2) The second table uses an NSPredicate to filter the array and show
only the entries where the boolean property is true.
3) The third table is the opposite of #2, it shows entries where the
boolean property is false.
For clarity: I'm using a unique NSArrayController for each of the
above, instantiated in my nib file.
So on load, the boolean property is set by some simple image
processing ( I'm filtering a folder of images into two sets based on
analysis of the images' pixels ).
So far, this works. I see the right images showing up in the
aforementioned tables.
However, I'd like to be able to manually override the results of the
image processing -- say due to false positive or whatever -- and as
such I put a checkbox in the first table ( the "all" table ) which
toggles that boolean property.
The trouble is that toggling that boolean property on an entry doesn't
update the contents of the two filtered arrays.
I figure there's got to be some way to make the array controllers for
those filtered tables know that the values have changed. In the past,
I've done some kind of hacky stuff to make this work, such as binding
a faux property in my app/doc controller to the array controller using
"arrangeObjects.propertyName" -- then in my +initialize method I
passed those faux properties to setKeys:
triggerChangeNotificationsForDependentKey: to get the change recognized.
If something like that's really the only way to go, then that's fine.
But I feel like there's got to be some way that's a little more elegant.
Note: I'm not using core data -- my "model" is just an NSArray of my
image processing objects.
Thanks in advance,
shamyl zakariya
"authentic frontier gibberish"
_______________________________________________
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