diff --git a/SDImageCache.m b/SDImageCache.m index 33911209..6de0e5bb 100644 --- a/SDImageCache.m +++ b/SDImageCache.m @@ -41,7 +41,8 @@ static SDImageCache *instance; cacheInQueue.maxConcurrentOperationCount = 1; cacheOutQueue = [[NSOperationQueue alloc] init]; cacheOutQueue.maxConcurrentOperationCount = 1; - +#if !TARGET_OS_IPHONE +#else // Subscribe to app events [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearMemory) @@ -64,6 +65,7 @@ static SDImageCache *instance; object:nil]; } #endif +#endif } return self; @@ -98,7 +100,7 @@ static SDImageCache *instance; { const char *str = [key UTF8String]; unsigned char r[CC_MD5_DIGEST_LENGTH]; - CC_MD5(str, strlen(str), r); + CC_MD5(str, (CC_LONG)strlen(str), r); NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", 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]]; @@ -124,8 +126,14 @@ static SDImageCache *instance; UIImage *image = [[self imageFromKey:key fromDisk:YES] retain]; // be thread safe with no lock if (image) { +#if !TARGET_OS_IPHONE + NSArray* representations = [image representations]; + NSData* jpegData = [NSBitmapImageRep representationOfImageRepsInArray: representations usingType: NSJPEGFileType properties:nil]; + [fileManager createFileAtPath:[self cachePathForKey:key] contents:jpegData attributes:nil]; +#else [fileManager createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil]; [image release]; +#endif } } diff --git a/SDImageCacheDelegate.h b/SDImageCacheDelegate.h index 947a90ad..85d1d16b 100644 --- a/SDImageCacheDelegate.h +++ b/SDImageCacheDelegate.h @@ -6,7 +6,7 @@ // Copyright 2010 Dailymotion. All rights reserved. // -#import +#import "SDWebImageCompat.h" @class SDImageCache; diff --git a/SDWebImageCompat.h b/SDWebImageCompat.h new file mode 100644 index 00000000..24effc4d --- /dev/null +++ b/SDWebImageCompat.h @@ -0,0 +1,21 @@ +// +// SDWebImageCompat.h +// SDWebImageCompat +// +// Created by Jamie Pinkham on 3/15/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import + +#if !TARGET_OS_IPHONE +#import +#ifndef UIImage +#define UIImage NSImage +#endif +#ifndef UIImageView +#define UIImageView NSImageView +#endif +#else +#import +#endif diff --git a/SDWebImageDownloader.h b/SDWebImageDownloader.h index 863a2e3c..0534406a 100644 --- a/SDWebImageDownloader.h +++ b/SDWebImageDownloader.h @@ -8,6 +8,7 @@ #import #import "SDWebImageDownloaderDelegate.h" +#import "SDWebImageCompat.h" extern NSString *const SDWebImageDownloadStartNotification; extern NSString *const SDWebImageDownloadStopNotification; diff --git a/SDWebImageDownloaderDelegate.h b/SDWebImageDownloaderDelegate.h index 08939be9..c33f87b0 100644 --- a/SDWebImageDownloaderDelegate.h +++ b/SDWebImageDownloaderDelegate.h @@ -6,6 +6,8 @@ * file that was distributed with this source code. */ +#import "SDWebImageCompat.h" + @class SDWebImageDownloader; @protocol SDWebImageDownloaderDelegate diff --git a/SDWebImageManager.h b/SDWebImageManager.h index 256de0b8..96809fac 100644 --- a/SDWebImageManager.h +++ b/SDWebImageManager.h @@ -6,7 +6,7 @@ * file that was distributed with this source code. */ -#import +#import "SDWebImageCompat.h" #import "SDWebImageDownloaderDelegate.h" #import "SDWebImageManagerDelegate.h" #import "SDImageCacheDelegate.h" diff --git a/UIImageView+WebCache.h b/UIImageView+WebCache.h index 517735f5..9d93a8ef 100644 --- a/UIImageView+WebCache.h +++ b/UIImageView+WebCache.h @@ -6,7 +6,7 @@ * file that was distributed with this source code. */ -#import +#import "SDWebImageCompat.h" #import "SDWebImageManagerDelegate.h" @interface UIImageView (WebCache)