SSOperations 0.1.0

SSOperations 0.1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版本2015年3月

Jonathan Hersh维护。



  • Jonathan Hersh

Circle CI

便捷的NSOperationQueueNSBlockOperation辅助工具。

《SSOperations》为我的应用程序中的各种操作提供动力,该应用程序是MUDRammer -适用于iPhone和iPad的现代MUD客户端

安装

使用CocoaPods进行安装。将其添加到您的Podfile

pod 'SSOperations', :head # YOLO

SSBlockOperation & SSBlockOperationBlock

NSBlockOperation的一个简单子类,当执行时传递自身作为输入。

主要优点是您可以在运行时检查操作是否已取消,如果是,可以适当地进行清理并退出。

SSBlockOperationBlock anOperationBlock = ^(SSBlockOperation *operation) {
    if( [operation isCancelled] )
        return;

    // Do some stuff…

    if( [operation isCancelled] )
        return;

    // Do some more stuff...
};

// Submit this operation to a queue for execution.
[myOperationQueue ss_addBlockOperationWithBlock:anOperationBlock];

NSOperationQueue + SSAdditions.h

创建一个NSOperationQueue并提交SSBlockOperationBlock进行执行的一个便捷方式。

// An operation queue that runs operations serially.
NSOperationQueue *serialQueue = [NSOperationQueue ss_serialOperationQueue];

// An operation queue that runs up to 3 operations concurrently.
NSOperationQueue *threeOperationQueue = [NSOperationQueue ss_concurrentQueueWithConcurrentOperations:3

// An operation queue that runs as many concurrent operations as the system deems appropriate.
// It has a name!
NSOperationQueue *concurrentQueue = [NSOperationQueue ss_concurrentMaxOperationQueueNamed:@"My queue"];

// Submit an `SSBlockOperationBlock` for processing.
[anOperationQueue ss_addBlockOperationWithBlock:anOperationBlock];

感谢!

SSOperations@jhersh的生产产品——(电子邮件 | @jhersh)