0

AppDelgate のプロパティにオブザーバーを追加しようとしていますが、何らかの理由で機能しないため、何か不足しているかどうかを知りたいだけです。

私が使用しているコードは次のとおりです。

AppDelegate.h

@property(strong, nonatomic) NSDictionary * dataDict;

AppDelegate.m

-(void)viewDidLoad{
[(AppDelegate *)[[UIApplication sharedApplication] delegate] addObserver:self forKeyPath:@"dataDict" options:0 context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    // Do something

}
4

1 に答える 1