CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

SYOperationQueue 1.0.3

SYOperationQueue 1.0.3

TestsTested
LangLanguage Obj-CObjective C
License NOASSERTION
ReleasedLast Release Feb 2019

Maintained by Stanislas Chevallier.



  • By
  • Stan Chevallier

SYOperationQueue

An operation queue subclass that allows LIFO style queuing and a max number of operations.

I made it to allow loading images in a large UICollectionView while scrolling. When set properly this will load images needed by the collection view even if the user scrolls, and loading first images needed quickly.

Header

This queue doesn't inherit from NSOperationQueue but should expose a similar enough interface to easily switch between the two.

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