我们最近将我们的应用程序发布到了appstore,几乎立即在SDWebImageManager中出现了一些崩溃:imageDownloader:didFinishWithImage: 堆栈的顶部看起来像:
0 libobjc.A.dylib 0x33c28c98 objc_msgSend + 16
1 CoreFoundation 0x308f0571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 25
2 Ourcode 0x0001d98f -SDWebImageManager imageDownloader:didFinishWithImage:
3 CoreFoundation 0x308f0571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 25
4 Ourcode 0x0001cb03 -SDWebImageDownloader connectionDidFinishLoading:
我们有最新的SD代码,可以在此函数中保留委托。 只要我们的代表被正确创建,我就不会看到我们如何处理这种情况。在我看来,performSelector on的delgate已被释放。但SDWebImageManager重新获得委托。
imageDownloader的相关代码:didFinishWithImage:是:
- (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithImage:(UIImage *)image
{
[downloader retain];
SDWebImageOptions options = [[downloader.userInfo objectForKey:@"options"] intValue];
// Notify all the downloadDelegates with this downloader
for (NSInteger idx = (NSInteger)[downloaders count] - 1; idx >= 0; idx--)
{
NSUInteger uidx = (NSUInteger)idx;
SDWebImageDownloader *aDownloader = [downloaders objectAtIndex:uidx];
if (aDownloader == downloader)
{
id<SDWebImageManagerDelegate> delegate = [[[downloadDelegates objectAtIndex:uidx] retain] autorelease];
if (image)
{
if ([delegate respondsToSelector:@selector(webImageManager:didFinishWithImage:)])
{
[delegate performSelector:@selector(webImageManager:didFinishWithImage:) withObject:self withObject:image];
}
}