NSURLConnectionDelegate connection:didReceiveData not working(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,但是
I am using this method to initiate the NSURLConnection, but the
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
没有打电话..需要帮助
is not calling.. Need Help
提前致谢,世斌
推荐答案
没有唯一的答案,但是: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 中的 NSURLConnectionDelegate 协议
2) Check that you have properly declared that you conform to the NSURLConnectionDelegate protocol in the .h
3) 你是在处理或弄乱 runloops 吗?" 发送给委托的消息将在调用此方法的线程上发送.默认情况下,要使连接正常工作,调用线程的运行循环必须在默认运行循环模式下运行."
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 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:NSURLConnectionDelegate 连接:didReceiveData 不起作用
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
