|
@@ -41,7 +41,8 @@ static SDImageCache *instance; |
|
@@ -41,7 +41,8 @@ static SDImageCache *instance; |
41
|
cacheInQueue.maxConcurrentOperationCount = 1;
|
41
|
cacheInQueue.maxConcurrentOperationCount = 1;
|
42
|
cacheOutQueue = [[NSOperationQueue alloc] init];
|
42
|
cacheOutQueue = [[NSOperationQueue alloc] init];
|
43
|
cacheOutQueue.maxConcurrentOperationCount = 1;
|
43
|
cacheOutQueue.maxConcurrentOperationCount = 1;
|
44
|
-
|
44
|
+#if !TARGET_OS_IPHONE
|
|
|
45
|
+#else
|
45
|
// Subscribe to app events
|
46
|
// Subscribe to app events
|
46
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
47
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
47
|
selector:@selector(clearMemory)
|
48
|
selector:@selector(clearMemory)
|
|
@@ -64,6 +65,7 @@ static SDImageCache *instance; |
|
@@ -64,6 +65,7 @@ static SDImageCache *instance; |
64
|
object:nil];
|
65
|
object:nil];
|
65
|
}
|
66
|
}
|
66
|
#endif
|
67
|
#endif
|
|
|
68
|
+#endif
|
67
|
}
|
69
|
}
|
68
|
|
70
|
|
69
|
return self;
|
71
|
return self;
|
|
@@ -98,7 +100,7 @@ static SDImageCache *instance; |
|
@@ -98,7 +100,7 @@ static SDImageCache *instance; |
98
|
{
|
100
|
{
|
99
|
const char *str = [key UTF8String];
|
101
|
const char *str = [key UTF8String];
|
100
|
unsigned char r[CC_MD5_DIGEST_LENGTH];
|
102
|
unsigned char r[CC_MD5_DIGEST_LENGTH];
|
101
|
- CC_MD5(str, strlen(str), r);
|
103
|
+ CC_MD5(str, (CC_LONG)strlen(str), r);
|
102
|
NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
104
|
NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
103
|
r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]];
|
105
|
r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]];
|
104
|
|
106
|
|
|
@@ -124,8 +126,14 @@ static SDImageCache *instance; |
|
@@ -124,8 +126,14 @@ static SDImageCache *instance; |
124
|
UIImage *image = [[self imageFromKey:key fromDisk:YES] retain]; // be thread safe with no lock
|
126
|
UIImage *image = [[self imageFromKey:key fromDisk:YES] retain]; // be thread safe with no lock
|
125
|
if (image)
|
127
|
if (image)
|
126
|
{
|
128
|
{
|
|
|
129
|
+#if !TARGET_OS_IPHONE
|
|
|
130
|
+ NSArray* representations = [image representations];
|
|
|
131
|
+ NSData* jpegData = [NSBitmapImageRep representationOfImageRepsInArray: representations usingType: NSJPEGFileType properties:nil];
|
|
|
132
|
+ [fileManager createFileAtPath:[self cachePathForKey:key] contents:jpegData attributes:nil];
|
|
|
133
|
+#else
|
127
|
[fileManager createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil];
|
134
|
[fileManager createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil];
|
128
|
[image release];
|
135
|
[image release];
|
|
|
136
|
+#endif
|
129
|
}
|
137
|
}
|
130
|
}
|
138
|
}
|
131
|
|
139
|
|