Background
As for why , you see this discrepancy when starting notifications, it is probably due to how KVO works. You are observing the value of a property. In this case, statusBarHidden . But to receive notifications, this property must be changed using the creator that exists for it.
Notifications cannot happen magically, so it must be encoded as a side effect of the setter. (this is often done automatically for you when encoding your properties). However, a class that has this property can also select a direct ivar change. In this case, UIApplication has / has an internal _applicationFlags structure that contains
unsigned int statusBarHidden:1;
Thus, it is possible that setStatusBarHidden:withAnimation: simply modifies the underlying data element directly, which bypasses the installer needed to call your observer back.
Decision?
Regarding workarounds for you, you did not mention whether this application is for the application store or not (it may be for personal / hobbies, it may be a corporate application or it may be a jailbreak application).
One thing that might be an option for you is to use the swizzling method to replace the standard implementation of setStatusBarHidden:withAnimation: with one of your own. Your own implementation may simply call setStatusBarHidden: which will then turn on KVO again. Or, if you want to save the animation, you can probably use GCD to schedule setStatusBarHidden: to start after the time it takes setStatusBarHidden:withAnimation: to complete the animation. That way, you still get the animation, and also activate KVO by calling setStatusBarHidden:
I donβt understand if the swizzling method is rejected in the App Store apps. I thought it was (at least when swizzling methods on iOS systems), but according to this, it is either allowed or may slip .
Next question: βIf the swizzling method is really what Apple wants you to avoid, despite being in the public API , is there a way around this?β
If people in the stack overflow problems that I linked to were lying, it looks like she is viewing a review (at least sometimes). Thus, perhaps this is not verified automatically. Perhaps this is sometimes visually recognized by human testers who see that the standard function works differently, so what they output should be the result of the swizzling method. In this case, you actually do not want to use it to change the behavior of the status bar user interface, just to fix the notification so that it does not interfere with them.
Or they can search for selectors for well-known iOS APIs (used with swizzling). If this is the case, selectors built from strings can be easily confused to avoid detection .
Anyway, just some options ...