Failsafe a very common usage error (passing URL as NSString instead of NSURL)

This commit is contained in:
Olivier Poitrey 2011-10-01 00:38:44 +02:00
parent e9d43e443a
commit 7c06b3a314
1 changed files with 7 additions and 0 deletions

View File

@ -73,6 +73,13 @@ static SDWebImageManager *instance;
return;
}
// Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't
// throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString.
if ([url isKindOfClass:NSString.class])
{
url = [NSURL URLWithString:(NSString *)url];
}
// Check the on-disk cache async so we don't block the main thread
[cacheDelegates addObject:delegate];
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:delegate, @"delegate", url, @"url", [NSNumber numberWithBool:lowPriority], @"low_priority", nil];