我想使用NSURLConnection与我的服务器进行连接。我已经实现了很多次,但目前它在任何情况下都不会调用委托方法(成功/失败/超时)。我不明白为什么它会发生。NSURLConnection不调用委托方法
下面是我写的代码。
在.H我已经在.M
此获取调用,我已经通过把日志检查implenented NSURLConnectionDelegate
。
self.connection = nil;
self.connection = [[NSURLConnection alloc] initWithRequest:MyRequest delegate:self startImmediately:YES];
我的连接对象不是零。我已经impleneted
委托方法是
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection
我已经在所有这些推杆日志,但他们没有获取调用。
我也检查了我的服务器,&其工作正常。 我也连接到互联网。
任何人都可以抛出一些光,我失踪了。
您是否尝试过使用'connectionWithRequest:delegate:'而不是'initWithRequest:delegate:startImmediately:'? – Oyashiro 2012-07-20 14:50:03
是的,我尝试使用两个,但同样的问题 – JiteshW 2012-07-21 06:19:25
你可以添加更多的代码?何时以及如何创建请求? – Oyashiro 2012-07-23 07:11:31