【发布时间】:2023-03-08 02:21:01
【问题描述】:
当我在设备上运行应用程序时,没有调用 NSURLRequest 委托方法。虽然它在模拟器上完美运行。在请求完成之前我的视图加载也不是这种情况,因为我只能在连接接收到数据后才能加载视图。
我的代码请求网址在这里。非常感谢任何帮助。
- (void)viewWillAppear:(BOOL)animated
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://-dev01x/content"]; cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60];
[request setHTTPMethod:@"GET"];
_getData = [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSLog(@"HELLO %@",_getData);
}
【问题讨论】:
-
旁注 - 阅读文档,如果你重写
viewWillAppear:方法,你必须在你的实现中调用 super。你没有这样做。
标签: iphone objective-c ios ios4 nsurlconnection