gpt4 book ai didi

iphone - 已弃用的 NSURLConnection 方法,是否有替代方法?

转载 作者:搜寻专家 更新时间:2023-10-30 20:06:42 24 4
gpt4 key购买 nike

我正在设置一个 NSURLConnection 来访问远程服务器:

NSURL *url = [[NSURL alloc] initWithString:projectURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

使用以下委托(delegate)方法:

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

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

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

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse

所有这些方法都说“在 iOS 2.0 到 iOS 4.3 中可用”。我的问题是我应该以另一种方式为当前的 iOS5 做这件事吗?我需要异步传输,需要传递一个 NSURLCredential 来进行 UID/PWD 认证。

编辑:

所以如果我采用协议(protocol) <NSURLConnectionDelegate>在我的 header 中并使用上面的委托(delegate)方法我这样做是正确的吗?

最佳答案

对于 iOS 5,看起来你可以利用新的 NSURLConnectionDelegate protocol (为您链接的文档)。

And here's a related (or maybe even duplicate?) question that explains even better .

关于iphone - 已弃用的 NSURLConnection 方法,是否有替代方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9483484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com