0

オブジェクトが NSMutableDictionary に追加されたときに NSNotificationCenter で通知を受け取るにはどうすればよいですか?

また、不変の NSDictionary に関する通知はありますか?

4

1 に答える 1

1

継承の美しさ :)

#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
于 2012-08-03T13:36:42.143 に答える