WGBackgroundBlockOperation 0.1.0

WGBackgroundBlockOperation 0.1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2014 年 12 月

Wil Gieseler 维护。



  • Wil Gieseler

NSBlockOperation 的一个直接替代品,强自动将自己配置为后台任务。显然,仅限 iOS。

这样很棒,因为你不必跟踪任何讨厌的 UIBackgroundTaskIdentifier 或类似的东西。

安装

(待定) 将此行添加到您的应用程序的 Podfile 中

pod 'WGBackgroundBlockOperation'

用法

假设您有一个相当简单的长时间运行的任务

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

如果您的操作块生成了其他操作,您可能需要手动结束后台任务

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

贡献

  1. 分支
  2. 创建您的特性分支(git checkout -b my-new-feature
  3. 提交您的更改(git commit -am 'Add some feature'
  4. 将分支推送到(git push origin my-new-feature
  5. 创建一个新的拉取请求