Q:

Is it possible to have a function that returns true if my iOS application is currently in the foreground (active)? (SWIFT)

I would like to know that and use that function in a view controller, if possible.

A:

UIApplication.sharedApplication().applicationState == UIApplicationState.Active

