• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Implementing Smart Collections
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementing Smart Collections


  • Subject: Implementing Smart Collections
  • From: Drew McCormack <email@hidden>
  • Date: Sat, 24 Feb 2007 12:17:15 +0100

I've implemented smart collections based on Core Recipes. I register for notifications for changes made to the managed object context:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemsDidChange:) name:NSManagedObjectContextObjectsDidChangeNotification object:ManagedObjectContext()];


and refresh the collection if an object changes that has the entity corresponding to the collection. For example, to check updated objects:


- (void)itemsDidChange:(NSNotification *)notification {
NSEnumerator *enumerator;
id object;
BOOL refresh = NO;
NSEntityDescription *entity = [[self valueForKey:@"fetchRequest"] entity];


NSSet *updated = [[notification userInfo] objectForKey:NSUpdatedObjectsKey];

    enumerator = [updated objectEnumerator];
    while ((refresh == NO) && (object = [enumerator nextObject])) {
        if ([object entity] == entity) {
            refresh = YES;
        }
    }


The problem is, any update of any property of an object triggers a refresh, even if the property is not relevant to the smart collection. This is causing me the following problem: I have a text view that continuously updates the model, and pressing any key causes the smart collection to refresh, thereby causing the array controller to update its selection, and thereby the text view to lose focus.


What I really need to do is only refresh my smart collections when certain properties are changed, but there doesn't seem to be any way to find out what changed from the notification object passed above.

Is there a straightforward solution to this, or do I just have to give up on having continuously updating text views?

Drew McCormack


--------------------------------------------------------- Drew McCormack

www.macanics.net
www.macresearch.org

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Re: Emulating modifier keys
  • Next by Date: Call of super from a custom NSCell in a custom NSControl
  • Previous by thread: Re: Custom NSView That is iChat Chat Log Like
  • Next by thread: RE: Implementing Smart Collections
  • Index(es):
    • Date
    • Thread