Reputation: 1918
This awesome UIImageView
extension has the af_sharedImageRequestOperationQueue
, where max concurrent number set as
_af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount;
How to access this private field and set custom value for maxConcurrentOperationCount
? (I don't want to edit files under CocoaPods directly)
UPD: Thanks GeneratorOfOne, looks like the best solution for me. However, I decided to use SDWebImage, because it provides cache out of the box and allows to set maxConcurrentOperationCount
in a line of code.
Upvotes: 0
Views: 146
Reputation: 2636
As explained in the definition NSOperationQueueDefaultMaxConcurrentOperationCount is meant to return the correct amount of concurrent queues allowed based on system conditions.
Why would you want to limit it?
Upvotes: 0
Reputation: 21154
This is a private method which has a static NSOperationQueue. You could either go and poke the code directly which is not good to change the existing code for some librarues. I would suggest you to create a new UIImageView category, where you would expose this method and then you could set the maxConcurrentOperationCount on it.
Like,
@interface UIImageView(MyExtension)
+ (NSOperationQueue *)af_sharedImageRequestOperationQueue;
@end
@implementation UIImageView(MyExtension)
+ (void)load {
NSOperationQueue *queue = [self af_sharedImageRequestOperationQueue];
queue.maxConcurrentOperationCount = 5;
}
@end
Then, you could now include the extension in your class and set its maxConcurrentOperationCount.
Upvotes: 2