Skip to content

Commit

Permalink
Fix some warnings when most warnings are activated
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Poitrey committed Nov 11, 2009
1 parent 79c5fa1 commit 0bdd448
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
30 changes: 16 additions & 14 deletions SDImageCache.m
Expand Up @@ -15,11 +15,23 @@

@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];
Expand Down Expand Up @@ -69,17 +81,7 @@ - (void)dealloc
[super dealloc];
}

- (void)didReceiveMemoryWarning:(void *)object
{
[self clearMemory];
}

- (void)willTerminate
{
[self cleanDisk];
}

#pragma mark ImageCache (class methods)
#pragma mark SDImageCache (class methods)

+ (SDImageCache *)sharedImageCache
{
Expand All @@ -91,7 +93,7 @@ + (SDImageCache *)sharedImageCache
return instance;
}

#pragma mark ImageCache (private)
#pragma mark SDImageCache (private)

- (NSString *)cachePathForKey:(NSString *)key
{
Expand All @@ -110,7 +112,7 @@ - (void)storeKeyToDisk:(NSString *)key

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];
}
}
Expand Down
22 changes: 11 additions & 11 deletions SDWebImageManager.m
Expand Up @@ -16,7 +16,7 @@ @implementation SDWebImageManager

- (id)init
{
if (self = [super init])
if ((self = [super init]))
{
delegates = [[NSMutableArray alloc] init];
downloaders = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -78,17 +78,17 @@ - (void)cancelForDelegate:(id<SDWebImageManagerDelegate>)delegate
{
@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])
{
Expand All @@ -108,20 +108,20 @@ - (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithImage:(U
@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];
}
}
}
Expand Down

0 comments on commit 0bdd448

Please sign in to comment.