The following is not working:
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"windows"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:NULL];
Together with that, on the Observer side:
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSLog(@"never reached!");
}
Any clues?
N.B. My uber-goal is to get a notification when a (system-generated) UIAlertView is shown.
Self answering…
The right way to detect when an arbitrary UIAlertView is shown is to use NSNotificationCenter:
And then, inside:
Check if the UIWindow in question (accessible via notification.object) contains a sub-view which is an instance of UIAlertView