Testing whether a view is currently visible

When manipulating iOS UI from background threads, or in response to NSNotification messages, you won’t always be sure that the view your controller is working with is on-screen. How can you check?

Relatively easy. Here’s a simple check from within the context of a View’s ViewController:

if self.isViewLoaded() && self.view.window != nil { // do something }

This is appropriate when the “something” shouldn’t be executed unless the view is currently visible to the user.