Latest 0.1.0
License MIT
Platforms ios 5.0, requires ARC

A drop-in replacement for NSBlockOperation that automatically configures itself as a background task. iOS only, obviously.

This is nice because you don’t have to keep track of any pesky UIBackgroundTaskIdentifier or anything like that.


(pending) Add this line to your application’s Podfile:

pod 'WGBackgroundBlockOperation'


Say you have a pretty simple long-running task:

[NSOperationQueue.mainQueue addOperation:[WGBackgroundBlockOperation blockOperationWithBlock:^{
    [self someLongRunningTask];

If your operation block spawns other operations, you might want to end the background task manually:

__block WGBackgroundBlockOperation *op = [WGBackgroundBlockOperation blockOperationWithBlock:^{
    [self postAGiantImageToLetsSaySomeKindOfServerWithCompletionBlock:^{
       [self completeUpload];
       [op endBackgroundTask];
op.automaticallyEndsBackgroundTask = NO;
[NSOperationQueue.mainQueue addOperation:op];


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Latest podspec

    "name": "WGBackgroundBlockOperation",
    "version": "0.1.0",
    "summary": "A block operation that automatically works in the background on iOS.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Wil Gieseler": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "platforms": {
        "ios": "5.0"
    "requires_arc": true,
    "source_files": "Classes"

Pin It on Pinterest

Share This