Re: NSArrayController predicate filtering weirdness
Re: NSArrayController predicate filtering weirdness
- Subject: Re: NSArrayController predicate filtering weirdness
- From: Markus Spoettl <email@hidden>
- Date: Tue, 2 Feb 2010 18:13:53 +0100
On Feb 2, 2010, at 3:16 PM, Markus Spoettl wrote:
> It goes something like this:
>
> Filter using predicate A => arrangedObjects contains 4 objects (correct)
> Filter using predicate F => arrangedObjects contains 0 objects (incorrect)
> Filter using predicate B => arrangedObjects contains 2 objects (correct)
> Filter using predicate F => arrangedObjects contains 1 object (correct)
>
> Predicate F is identical in both cases (meaning it's the exact same object) also the content (unfiltered) of the array controller doesn't change between filter assignments.
Following up on this I also tried using -rearrangeObjects on the array controller after setting the filter predicate. This also fixes this problem.
Now the question for me is, when I set the filter predicate, am I supposed to have to call -rearrangeObjects manually? Up until now I don't do this and filtering works as expected (and has for a long time) in many different places of the application (except for the case reported in the original post) both on 10.5 and 10.6.
Documentation doesn't tell me what to do. It doesn't say that -setFilterPredicate: causes automatic rearrangement, but it obviously does something. It's not producing the correct result in this particular case, though.
Any advice? Just in case I paste the code that sets the filter predicate below.
Regards
Markus
- (void)activatePredicate:(NSPredicate *)predicate onController:(NSArrayController *)ctrlr
{
[ctrlr setFilterPredicate:predicate];
NSLog(@"arrangedObjects: %@", [ctrlr arrangedObjects]); // reports 0 objects
[ctrlr rearrangeObjects];
NSLog(@"arrangedObjects: %@", [ctrlr arrangedObjects]); // reports 1 object
}
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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