The simplest way to answer the question: "Are there any UI events taking place right now?"
Objective-C Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A common adage of iOS development is to do as little as possible on the main thread so to not disrupt UI events. However, sometimes it is necessary to some work on the main thread and so we would prefer to do that work when the interface is mostly static (e.g. the user isn't dragging anything, scroll views aren't scrolling, etc...).

Now you can check at anytime if some kind of event tracking it taking place by doing:

if ([[OPEventTracker sharedTracker] isTracking])

My favorite place to use this is when saving an NSManagedObjectContext on a background thread that will then merge into the context on the main thread. In particular, I wait until event tracking stops before doing the save, that way if the merge takes some time it will not be noticeable in the UI.

You can also observe these events using the notifications OPEventTrackerNotifications.started and OPEventTrackerNotifications.stopped, e.g.

[[NSNotificationCenter defaultCenter] addObserver:self 


We love CocoaPods, so we recommend you use it.


Brandon Williams


OPEventTracker is available under the MIT license. See the LICENSE file for more info.