Temporarily disabled NSArrayController filterPredicate, or consult ManagedObjectContext?

Posted by ndg on Stack Overflow See other posts from Stack Overflow or by ndg
Published on 2010-06-03T12:41:40Z Indexed on 2010/06/08 11:32 UTC
Read the original article Hit count: 252

Filed under:
|
|
|

I have an NSArrayController which is bound to a class in my Managed Object Context. During runtime the NSArrayController can have a number of different filter predicates applied. At certain intervals, I want to iterate through my NSArrayController's contents regardless of the filter predicate applied to it.

To do this, I set the filterPredicate to nil and then reinstate it after having iterated through my array. This seems to work, but I'm wondering if it's best practice? Should I instead be polling my Managed Object Context manually?

NSPredicate *predicate = nil;
predicate = [myArrayController filterPredicate];
[myArrayController setFilterPredicate:nil];
for(MyManagedObject *object in [myArrayController arrangedObjects]) {
    // ...
}
[myArrayController setFilterPredicate:predicate];

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about data