【发布时间】:2010-06-24 14:45:37
【问题描述】:
在过去的 48 小时里,我一直在与此作斗争,并且搜索所有论坛都没有用。
我正在使用NSURLConnection 异步下载一系列网络文件。下载几个文件后随机崩溃,数量不固定。
请看下面的调用栈:
#0 0x35b634f4 in objc_msgSend
#1 0x3527c2ca in CFEqual
#2 0x3532e750 in __CFBasicHashStandardEquateKeys
#3 0x35330514 in ___CFBasicHashFindBucket_Linear
#4 0x3527c07c in CFBasicHashFindBucket
#5 0x3527bf5c in CFDictionaryGetValue
#6 0x31d15cb4 in HTTPMessage::copyConstantHeaderFieldValue
#7 0x31d6526c in URLRequest::copyConstantHeaderFieldValue
#8 0x31d606f8 in HTTPProtocol::getCacheStoragePolicy
#9 0x31d62cd0 in HTTPProtocol::updateForHeader
#10 0x31d64524 in HTTPProtocol::performHeaderRead
#11 0x31d64bf8 in HTTPProtocol::httpReadStreamEvent
#12 0x352c4302 in _signalEventSync
#13 0x352c427c in _cfstream_shared_signalEventSync
#14 0x352ed294 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
#15 0x352ef0e2 in __CFRunLoopDoSources0
#16 0x352f0058 in __CFRunLoopRun
#17 0x352970c2 in CFRunLoopRunSpecific
#18 0x35296fd0 in CFRunLoopRunInMode
#19 0x30a1f31c in +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
#20 0x309ef618 in -[NSThread main]
#21 0x30a75146 in __NSThread__main__
在 stackoverflow 上看到之前的线程后,发送重定向请求确实存在问题。建议的解决方案是实施
- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *) redirectResponse
{
return request;
}
我这样做了,但崩溃仍然存在。
崩溃前的行为也是,willSendRequest 被调用了两次,并且没有为此请求调用其他委托方法。它在 NSURLResponse 内部崩溃。
【问题讨论】:
-
仍然遇到问题可以帮助任何人吗?
-
嗨,没有人对此有任何线索,或者只是不想回答新用户?
-
忘记补充了,这个问题在 iOS 4.0 的 iPhone 上发生,在 3.0 上没有发生
-
我遇到了类似的情况,但情况不同。我的 EXC_BAD_ACCESS 在几秒钟后发生连接:didFailWithError:随机。我想不出任何解决方案。
标签: redirect crash nsurlconnection