Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Observing Collections



Quick question (hopefully):

I want to observe a key on objects residing in a collection (NSSet preferably but maybe an NSArray would work too). So, lets say I have a collection of 10 objects, each having a key "enabled", and I want to observe the value of the key "enabled" for each object, and also track new objects coming and going from the collection. (I want to do this because I want to maintain a separate collection of enabled objects, and I want to it always be up to date)

This seems fairly fundamental because I've hit this pattern several times, but I've yet to see an easy way to do it because when you need to manage object life cycles and add and remove observers fairly carefully. I've had to create a helper class to implement this pattern, but I figured people have come across this before and there is a much more elegant solution.

How would you do it?

Chad Woolf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.