Fix some warnings when most warnings are activated

This commit is contained in:
Olivier Poitrey 2009-11-11 15:43:11 +01:00
parent 79c5fa177d
commit 0bdd448ca8
2 changed files with 27 additions and 25 deletions

View File

@ -15,11 +15,23 @@ static SDImageCache *instance;
@implementation SDImageCache
#pragma mark SDImageCache (notification handlers)
- (void)didReceiveMemoryWarning:(void *)object
{
[self clearMemory];
}
- (void)willTerminate
{
[self cleanDisk];
}
#pragma mark NSObject
- (id)init
{
if (self = [super init])
if ((self = [super init]))
{
// Init the memory cache
memCache = [[NSMutableDictionary alloc] init];
@ -69,17 +81,7 @@ static SDImageCache *instance;
[super dealloc];
}
- (void)didReceiveMemoryWarning:(void *)object
{
[self clearMemory];
}
- (void)willTerminate
{
[self cleanDisk];
}
#pragma mark ImageCache (class methods)
#pragma mark SDImageCache (class methods)
+ (SDImageCache *)sharedImageCache
{
@ -91,7 +93,7 @@ static SDImageCache *instance;
return instance;
}
#pragma mark ImageCache (private)
#pragma mark SDImageCache (private)
- (NSString *)cachePathForKey:(NSString *)key
{
@ -110,7 +112,7 @@ static SDImageCache *instance;
if (image != nil)
{
[[NSFileManager defaultManager] createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, 1.0) attributes:nil];
[[NSFileManager defaultManager] createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil];
[image release];
}
}

View File

@ -16,7 +16,7 @@ static SDWebImageManager *instance;
- (id)init
{
if (self = [super init])
if ((self = [super init]))
{
delegates = [[NSMutableArray alloc] init];
downloaders = [[NSMutableArray alloc] init];
@ -78,17 +78,17 @@ static SDWebImageManager *instance;
{
@synchronized(self)
{
NSUInteger index = [delegates indexOfObjectIdenticalTo:delegate];
NSUInteger idx = [delegates indexOfObjectIdenticalTo:delegate];
if (index == NSNotFound)
if (idx == NSNotFound)
{
return;
}
SDWebImageDownloader *downloader = [[downloaders objectAtIndex:index] retain];
SDWebImageDownloader *downloader = [[downloaders objectAtIndex:idx] retain];
[delegates removeObjectAtIndex:index];
[downloaders removeObjectAtIndex:index];
[delegates removeObjectAtIndex:idx];
[downloaders removeObjectAtIndex:idx];
if (![downloaders containsObject:downloader])
{
@ -108,20 +108,20 @@ static SDWebImageManager *instance;
@synchronized(self)
{
// Notify all the delegates with this downloader
for (NSInteger index = [downloaders count] - 1; index >= 0; index--)
for (NSInteger idx = [downloaders count] - 1; idx >= 0; idx--)
{
SDWebImageDownloader *aDownloader = [downloaders objectAtIndex:index];
SDWebImageDownloader *aDownloader = [downloaders objectAtIndex:idx];
if (aDownloader == downloader)
{
id<SDWebImageManagerDelegate> delegate = [delegates objectAtIndex:index];
id<SDWebImageManagerDelegate> delegate = [delegates objectAtIndex:idx];
if (image && [delegate respondsToSelector:@selector(webImageManager:didFinishWithImage:)])
{
[delegate performSelector:@selector(webImageManager:didFinishWithImage:) withObject:self withObject:image];
}
[downloaders removeObjectAtIndex:index];
[delegates removeObjectAtIndex:index];
[downloaders removeObjectAtIndex:idx];
[delegates removeObjectAtIndex:idx];
}
}
}