SYOperationQueue 1.0.3

SYOperationQueue 1.0.3

测试已测试
Lang语言 Obj-CObjective C
许可协议 NOASSERTION
发布最后发布2019 年 2 月

Stanislas Chevallier 维护。



  • Stan Chevallier

SYOperationQueue

这是一个允许 LIFO 风格排队和最大操作数的操作队列子类。

我做这个是为了在滚动大 UICollectionView 时加载图像。当设置正确时,它将加载集合视图需要的图像,即使用户滚动,也会快速加载所需的第一张图像。

头文件

这个队列不是从 NSOperationQueue 继承,但应该提供足够相似的接口,以便轻松切换到两者之间。

typedef enum : NSUInteger {
    SYOperationQueueModeFIFO,
    SYOperationQueueModeLIFO,
} SYOperationQueueMode;

@interface SYOperationQueue : NSObject

@property (readonly, copy) NSArray <__kindof NSOperation *> *operations;
@property (readonly) NSUInteger operationCount;
@property (getter=isSuspended) BOOL suspended;
@property (copy) NSString *name;

@property (nonatomic) NSInteger maxConcurrentOperationCount;
@property (nonatomic) NSInteger maxSurvivingOperations;
@property (nonatomic) SYOperationQueueMode mode;

- (void)addOperation:(__kindof NSOperation *)op;
- (void)addOperationWithBlock:(void(^)(void))block;
- (void)cancelAllOperations;

@end