【发布时间】:2009-08-26 21:36:29
【问题描述】:
我有下一个代码:
NSURL *url = [NSURL URLWithString:@"http:...."];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [""soapMessage"" length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [""soapMessage"" dataUsingEncoding:NSUTF8StringEncoding]];
[theRequest setTimeoutInterval:20];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
[theConnection start];
然后,有时,当我在我的界面中分配用于启动新连接的按钮中多次单击 (只是尝试在哪里使应用程序失败),连接不会给出回复(我发送了请求,但看起来被阻止了)。
我想知道“setTimeoutInterval”的用途是什么?以及是否有一些方法可以限制等待一个响应的时间?
谢谢!
【问题讨论】:
标签: objective-c iphone-sdk-3.0 error-handling connection