views:

19

answers:

1

Hey,

Is it possible to to subclass NSMutableSet? I need to do this in order to not retain objects contained in this set. The purpose todo that is to make an set of observers and those do not need to be retained.

Is it possible to do this or maybe you have an another solution.

Needles to say, I do know KVO but the pattern I have described above suites me better.

Cheers, Lukasz

+2  A: 

One possibility would be to use CFMutableSet. When you create one with CFSetCreateMutable, you can specify callbacks that define how retain and release work. And this is toll-free bridged with NSMutableSet.

JWWalker
+1 this is the proper way to do this. Subclassing `NSMutableSet` would be rather horrendous.
Dave DeLong
Also check out `NSHashTable`.
Ahruman