我搜索过很多关于NSURLConnection漏洞问题的文章,但是没有一个能给出明确答案,说明克服这些漏洞的解决方案是什么。 我创建了一个异步连接,每次建立连接时,都会出现GeneralBlock-3584泄漏。有时负责的库显示为Foundation [NSThread start]框架。 GeneralBlock-3584的一些实例具有CFNetwork HostLookup_Master :: HostLookup_Master(__ CFString const *,InheritEnum< _ExtendedHostInfoType,CFHostInfoType>,__ CFHost *,CFStreamError *)作为负责帧。 我尝试按照一些建议将NSURLCache大小设置为0。但是,即使这样也行不通。
以下是我的连接器类:
-(void) connectToUrl:(NSString*)urlStr withDelegate:(id)theDelegate{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
self.delegate = theDelegate;
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[NSURLConnection connectionWithRequest:request delegate:self];
[pool release];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
if(xmlResponse == nil){
xmlResponse = [[NSMutableString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
}
else{
NSMutableString *temp = [[NSMutableString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
[xmlResponse appendString:temp];
[temp release];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[self.delegate connectionDidFinish:self];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
[self.delegate connectionDidFail:self];
}
我正在调用此连接器类的connectToUrl:(NSString *)urlStr withDelegate:(id)theDelegate方法,如下所示:
Connector *con = [[Connector alloc] init];
[con connectToUrl:urlStr withDelegate:self];
我在委托类的connectionDidFinish和connectionDidFail方法中发布'con'。
请为GeneralBlock-3584泄漏建议解决方案。我一直在绞尽脑汁。
答案 0 :(得分:0)
自iOS4以来泄密已经消失。