Fix ARC compilation warning breaking some non-ARC projects (fix #229)
This commit is contained in:
parent
e3d8bc8daf
commit
d3b5fd2bd2
|
@ -48,6 +48,7 @@
|
|||
531041DA157EAFA400BBABC3 /* UIButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 53922D93148C56230056699D /* UIButton+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
531041DB157EAFA400BBABC3 /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 53922D95148C56230056699D /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
531041DC157EAFA400BBABC3 /* MKAnnotationView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 535699B415113E7300A4C397 /* MKAnnotationView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
53406750167780C40042B59E /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = 5340674F167780C40042B59E /* SDWebImageCompat.m */; };
|
||||
53761309155AD0D5005750A4 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 53922D86148C56230056699D /* SDImageCache.m */; };
|
||||
5376130A155AD0D5005750A4 /* SDWebImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 53922D8A148C56230056699D /* SDWebImageDecoder.m */; };
|
||||
5376130B155AD0D5005750A4 /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 53922D8C148C56230056699D /* SDWebImageDownloader.m */; };
|
||||
|
@ -83,6 +84,7 @@
|
|||
530E49E416460AE2002868E7 /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDownloaderOperation.m; sourceTree = "<group>"; };
|
||||
530E49E71646388E002868E7 /* SDWebImageOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageOperation.h; sourceTree = "<group>"; };
|
||||
531041E0157EAFA400BBABC3 /* libSDWebImage+MKAnnotation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libSDWebImage+MKAnnotation.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5340674F167780C40042B59E /* SDWebImageCompat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCompat.m; sourceTree = "<group>"; };
|
||||
535699B415113E7300A4C397 /* MKAnnotationView+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "MKAnnotationView+WebCache.h"; path = "SDWebImage/MKAnnotationView+WebCache.h"; sourceTree = SOURCE_ROOT; };
|
||||
535699B515113E7300A4C397 /* MKAnnotationView+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "MKAnnotationView+WebCache.m"; path = "SDWebImage/MKAnnotationView+WebCache.m"; sourceTree = SOURCE_ROOT; };
|
||||
53761325155AD0D5005750A4 /* libSDWebImage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDWebImage.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -162,6 +164,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
53922D88148C56230056699D /* SDWebImageCompat.h */,
|
||||
5340674F167780C40042B59E /* SDWebImageCompat.m */,
|
||||
530E49E71646388E002868E7 /* SDWebImageOperation.h */,
|
||||
53922DAB148C56810056699D /* Downloader */,
|
||||
53922DAA148C56470056699D /* Cache */,
|
||||
|
@ -381,6 +384,7 @@
|
|||
5376130E155AD0D5005750A4 /* UIButton+WebCache.m in Sources */,
|
||||
5376130F155AD0D5005750A4 /* UIImageView+WebCache.m in Sources */,
|
||||
530E49EC16464C84002868E7 /* SDWebImageDownloaderOperation.m in Sources */,
|
||||
53406750167780C40042B59E /* SDWebImageCompat.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -13,10 +13,6 @@
|
|||
#error SDWebImage does not support Objective-C Garbage Collection
|
||||
#endif
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
|
||||
#endif
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0
|
||||
#error SDWebImage doesn't support Deployement Target version < 5.0
|
||||
#endif
|
||||
|
@ -57,43 +53,4 @@
|
|||
#define SDDispatchQueueSetterSementics assign
|
||||
#endif
|
||||
|
||||
NS_INLINE UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData)
|
||||
{
|
||||
if (!imageOrData)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIImage *image = nil;
|
||||
if ([imageOrData isKindOfClass:[NSData class]])
|
||||
{
|
||||
image = [[UIImage alloc] initWithData:(NSData *)imageOrData];
|
||||
}
|
||||
else if ([imageOrData isKindOfClass:[UIImage class]])
|
||||
{
|
||||
image = (UIImage *)imageOrData;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
||||
{
|
||||
CGFloat scale = 1.0;
|
||||
if (path.length >= 8)
|
||||
{
|
||||
// Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
|
||||
NSRange range = [path rangeOfString:@"@2x." options:0 range:NSMakeRange(path.length - 8, 5)];
|
||||
if (range.location != NSNotFound)
|
||||
{
|
||||
scale = 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
|
||||
image = scaledImage;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
extern UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// SDWebImageCompat.m
|
||||
// SDWebImage
|
||||
//
|
||||
// Created by Olivier Poitrey on 11/12/12.
|
||||
// Copyright (c) 2012 Dailymotion. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SDWebImageCompat.h"
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
|
||||
#endif
|
||||
|
||||
UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData)
|
||||
{
|
||||
if (!imageOrData)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIImage *image = nil;
|
||||
if ([imageOrData isKindOfClass:[NSData class]])
|
||||
{
|
||||
image = [[UIImage alloc] initWithData:(NSData *)imageOrData];
|
||||
}
|
||||
else if ([imageOrData isKindOfClass:[UIImage class]])
|
||||
{
|
||||
image = (UIImage *)imageOrData;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
||||
{
|
||||
CGFloat scale = 1.0;
|
||||
if (path.length >= 8)
|
||||
{
|
||||
// Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
|
||||
NSRange range = [path rangeOfString:@"@2x." options:0 range:NSMakeRange(path.length - 8, 5)];
|
||||
if (range.location != NSNotFound)
|
||||
{
|
||||
scale = 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
|
||||
image = scaledImage;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
Loading…
Reference in New Issue