iOS 后台调度任务 Selene from LinkedIn

码农软件 · 软件分类 · 其他(Others) · 2019-07-18 17:14:17

软件介绍

Selene 是一个 iOS 库,用于在后台调度任务的执行。

使用:

1) 添加 fetch 后台模式到你 app 的 Info.plist 文件。

2) 创建一个任务

任务必须符合 SLNTaskProtocol。 例如:

@interface SampleTask: NSObject<SLNTaskProtocol>
@end
@implementation SampleTask
+ (NSString *)identifier {
  return NSStringFromClass(self);
}
+ (NSOperation *)operationWithCompletion:(SLNTaskCompletion_t)completion {
  NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
    // Do some work ....
    completion(UIBackgroundFetchResultNoData);
  }];
  return operation;
}
+ (CGFloat)averageResponseTime {
  return 5.0;
}
+ (SLNTaskPriority)priority {
  return SLNTaskPriorityLow;
}
@end

3) 添加任务类调度

NSArray *tasks = @[[SomeTask class]];
// Run the scheduler every 5 minutes
[SLNScheduler setMinimumBackgroundFetchInterval:60 * 5];
// Add the tasks
[SLNScheduler scheduleTasks:tasks];

在应用程序委托:

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  [SLNScheduler startWithCompletion:completionHandler];
}

本文地址:https://codercto.com/soft/d/10417.html

Complexity and Approximation

Complexity and Approximation

G. Ausiello、P. Crescenzi、V. Kann、Marchetti-sp、Giorgio Gambosi、Alberto M. Spaccamela / Springer / 2003-02 / USD 74.95

This book is an up-to-date documentation of the state of the art in combinatorial optimization, presenting approximate solutions of virtually all relevant classes of NP-hard optimization problems. The......一起来看看 《Complexity and Approximation》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具