forked from jakemarsh/JMImageCache
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJMImageCache.h
More file actions
62 lines (43 loc) · 2.27 KB
/
JMImageCache.h
File metadata and controls
62 lines (43 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// JMImageCache.h
// JMCache
//
// Created by Jake Marsh on 2/7/11.
// Copyright 2011 Jake Marsh. All rights reserved.
//
@class JMImageCache;
@protocol JMImageCacheDelegate <NSObject>
@optional
- (void) cache:(JMImageCache *)c didDownloadImage:(UIImage *)i forURL:(NSURL *)url;
- (void) cache:(JMImageCache *)c didDownloadImage:(UIImage *)i forURL:(NSURL *)url key:(NSString*)key;
@end
@interface JMImageCache : NSCache
@property (nonatomic) BOOL memoryOnlyCache;
// Global cache for easy use. Located in 'Library/Caches/JMCache', no memory limit
+ (JMImageCache *) sharedCache;
// Opitionally create a different JMImageCache instance with it's own cache directory
- (id) initWithCacheDirectory:(NSString *)cacheDirectory;
- (id) initWithCacheDirectory:(NSString *)cacheDirectory maxMemoryBytesSize:(NSUInteger)bytesSize;
- (void) imageForURL:(NSURL *)url key:(NSString *)key completionBlock:(void (^)(UIImage *image))completion;
- (void) imageForURL:(NSURL *)url completionBlock:(void (^)(UIImage *image))completion;
- (UIImage *) cachedImageForKey:(NSString *)key;
- (UIImage *) cachedImageForURL:(NSURL *)url;
- (UIImage *) imageForURL:(NSURL *)url key:(NSString*)key delegate:(id<JMImageCacheDelegate>)d;
- (UIImage *) imageForURL:(NSURL *)url delegate:(id<JMImageCacheDelegate>)d;
- (UIImage *) imageFromDiskForKey:(NSString *)key;
- (UIImage *) imageFromDiskForKey:(NSString *)key bytesSize:(NSUInteger *)bytesSize;
- (UIImage *) imageFromDiskForURL:(NSURL *)url;
- (NSString *) imageFromDiskURLForURL:(NSURL *)url;
// bytesSize is ignored if no maxMemoryBytesSize was informed or set to 0
- (void) setImage:(UIImage *)i forKey:(NSString *)key bytesSize:(NSUInteger)bytesSize;
- (void) setImage:(UIImage *)i forURL:(NSURL *)url bytesSize:(NSUInteger)bytesSize;
- (void) removeImageForKey:(NSString *)key;
- (void) removeImageForURL:(NSURL *)url;
- (UIImage *) setData:(NSData *)data forKey:(NSString *)key;
- (UIImage *) setData:(NSData *)data forURL:(NSURL *)url;
- (void) writeData:(NSData *)data toPath:(NSString *)path;
- (void) performDiskWriteOperation:(NSInvocation *)invoction;
- (void) removeImagesFromMemory;
- (void) adjustCacheSizeTo:(unsigned long long)bytesSize;
- (void) adjustCacheSizeBetweenMin:(unsigned long long)minBytesSize max:(unsigned long long)maxBytesSize;
@end