- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在植入简单的 NSURLConnection 时遇到了这个奇怪的问题...
调用了 didReceiveData 方法,我很乐意尝试附加接收数据,但是... nada!
肯定有一些数据(如长度所示,但 appendData 不附加数据!
我开始思考这个问题,我需要一些帮助,以免为时已晚:-)
这里有一些代码要看:
我的标题...
@interface ActionViewController : UITableViewController {
Site *site;
NSURLConnection *siteConnection;
NSMutableData *receivedData;
UIView *waitView;
UIActivityIndicatorView *activityIndicator;
int nConnections;
BOOL fail;
}
我的实现..
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
// Append the new data to receivedData.
NSLog(@"Received %d bytes of data",[data length]);
[receivedData appendData:data];
NSLog(@"Received %d bytes of data",[receivedData length]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[activityIndicator stopAnimating];
waitView.hidden = YES;
// release the connection
[connection release];
}
控制台输出...
[Session started at 2010-08-21 21:27:55 -0400.]
2010-08-21 21:28:19.263 myApp[2042:207] Received 108 bytes of data
2010-08-21 21:28:19.263 myApp[2042:207] Received 0 bytes of data
2010-08-21 21:28:19.263 myApp[2042:207] Succeeded! Received 0 bytes of data
我不明白!帮助!!!
顺便说一句,数据是一个简单的 xml 结果,看起来像这样......
<donnee>0</donnee><donnee>0</donnee><donnee>0</donnee><donnee>1</donnee><donnee>0</donnee><donnee>0</donnee>
最佳答案
好吧,我在这个网站上关于 NSMutableData 的另一个问题中得到了答案。 ...忘记初始化了! (代码 18 或向 nil 发送消息的剩余部分是 Objective-C 的一个 NICE 特性)
receivedData = [[NSMutableData alloc] init];
关于nsurlconnection - NSURLConnection 的 didReceiveData 方法中 appendData 的奇怪问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3539745/
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
要附加一个简单的字符串键值对,我们在对象 C 中执行此操作 NSMutableData *body = [NSMutableData data]; [body appendData:[[NSSt
我在植入简单的 NSURLConnection 时遇到了这个奇怪的问题... 调用了 didReceiveData 方法,我很乐意尝试附加接收数据,但是... nada! 肯定有一些数据(如长度所示,
我在我的 iOS 应用程序中使用 EGOTableViewPullRefresh 库。为了实现它,我必须将原始类从 UIViewController 的子类更改为 UITableViewControl
我是一名优秀的程序员,十分优秀!