AsyncBlockOperation 1.0.1

AsyncBlockOperation 1.0.1

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

Suyeol Jeon 维护。



  • 作者
  • devxoul

用于支持异步块的 NSOperation 子类。

概述

Swift

import AsyncBlockOperation

let queue = NSOperationQueue()

/// Method 1. Using `AsyncBlockOperation` object
let operation = AsyncBlockOperation { op in
    op.complete() // call this method when async task finished
}
queue.addOperation(operation)

/// Method 2. Using `NSOperationQueue` method
queue.addOperationWithAsyncBlock { op in
    op.complete()
}

Objective-C

#import <AsyncBlockOperation/AsyncBlockOperation.h>

NSOperationQueue *queue = [[NSOperationQueue alloc] init];

// Method 1. Using `AsyncBlockOperation` object
AsyncBlockOperation *operation = [AsyncBlockOperation blockOperationWithBlock:^(AsyncBlockOperation *op) {
    [op complete]; // call this method when async task finished
}];
[queue addOperation:operation];

// Method 2. Using `NSOperationQueue` method
[queue addOperationWithAsyncBlock:^(AsyncBlockOperation *op) {
    [op complete];
}];

安装

我建议您使用 CocoaPods,它是 Cocoa 的依赖项管理器。

Podfile

pod 'AsyncBlockOperation', '~> 1.0'

许可证

AsyncBlockOperation 使用 MIT 许可证。请参阅 LICENSE 文件获取更多信息。