オブジェクトが 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