NSURLConnectionDelegate连接:didReceiveData不工作 [英] NSURLConnectionDelegate connection:didReceiveData not working

查看:109
本文介绍了NSURLConnectionDelegate连接:didReceiveData不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些关于NSURLConnectionDelegate方法的帮助。

I need some help regarding the NSURLConnectionDelegate method.

- (void)startDownload {
NSString *URLString = [NSString stringWithFormat:appRecord.imageURLString]; 
NSURL *url = [NSURL URLWithString:URLString];   
NSURLRequest *request = [NSURLRequest requestWithURL:url];

imageConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];  
if(imageConnection) {
    activeDownload = [NSMutableData data];
}
}

我正在使用这种方法来启动NSURLConnection,但是连接:(NSURLConnection *)连接didReceiveData:(NSData *)数据

I am using this method to initiate the NSURLConnection, but the

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

没有调用..需要帮助

提前感谢
Shibin

Thanks in advance, Shibin

推荐答案

没有单个答案,但
1)放一些NSLogs来显示URL,然后验证它正确生成并返回数据

No single answer but: 1) Put some NSLogs in to display the URL and then validate that it is generated correctly and does return data

2)检查您是否已正确声明您符合.h

2) Check that you have properly declared that you conform to the NSURLConnectionDelegate protocol in the .h

3)你是穿线还是弄乱跑步? 给代理的消息将被发送到调用此方法的线程上。默认情况下,为使连接正常工作,调用线程的运行循环必须以默认运行循环模式运行。

3) Are you threading or messing with the runloops ? " Messages to the delegate will be sent on the thread that calls this method. By default, for the connection to work correctly the calling thread’s run loop must be operating in the default run loop mode."

这篇关于NSURLConnectionDelegate连接:didReceiveData不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆