From ec6b6e72675ae73fbcdc88d075ddfe9fe3d91009 Mon Sep 17 00:00:00 2001 From: Gabriele Petronella Date: Tue, 12 Aug 2014 11:23:31 +0200 Subject: [PATCH] More explicit error message in case of nil completedBlock NSParameterAssert doesn't provide enough information for understanding the API misuse. Pointing the API user to SDWebImagePrefetcher makes more sense, as a nil completedBlock most likely signifies the intention of prefetching the image. --- SDWebImage/SDWebImageManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index c5d9b7ae..89718cb9 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -112,7 +112,7 @@ progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionWithFinishedBlock)completedBlock { // Invoking this method without a completedBlock is pointless - NSParameterAssert(completedBlock); + NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); // 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.