如何知道 NSURLRequest 何时完成加载

发布于 2024-12-05 23:04:43 字数 203 浏览 1 评论 0原文

我正在实现一个显示一些 Twitter 数据的应用程序,在 wifi 上工作时没问题,但在 3g 崩溃时,我得出的结论是,因为获取填充表的数据的 NSURLRequest 需要更长的加载时间,因此表结束当键还没有加载时调用一个对象来获取键,

所以问题是, - 我如何知道 NSURLRequest 何时完成加载? [我检查了类参考但没有看到它?]

非常感谢!

Im implementing an app that shows some Twitter data, when is working on wifi is ok, but on 3g crashes, I have come to the conclusion that is because the NSURLRequest that fetchs the data that populates the table takes longer to load so the table ends up calling an object for key, when the keys havent even loaded,

So the question is,
- how can I know when the NSURLRequest finished loading? [I checked the Class Reference but didnt see it??]

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不是你的备胎 2024-12-12 23:04:43

委托方法在请求的相应 NSURLConnection 上调用,例如,

    urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

您将收到各种回调,包括完成的回调,如下所示:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{}

其他委托回调有:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection{

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

The delegate methods are invoked on the request's corresponding NSURLConnection, e.g.

    urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

You will then receive various callbacks included the finished callback as follows:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{}

Other delegate callbacks are:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection{

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文