将对象添加到 NSMutableDictionary 时,如何使用 NSNotificationCenter 获取通知?
还有关于不可变 NSDictionary 的通知吗?
将对象添加到 NSMutableDictionary 时,如何使用 NSNotificationCenter 获取通知?
还有关于不可变 NSDictionary 的通知吗?
继承之美:)
#define kSomeDictionarySetAValue @"SomeDictionarySetAValue"
@interface SomeDictionary : NSMutableDictionary
@end
@implementation SomeDictionary
- (void) setValue:(id)value forKey:(NSString *)key
{
[super setValue:value forKey:key];
[[NSNotificationCenter defaultCenter] postNotificationName:kSomeDictionarySetAValue
object:self];
}
@end