【问题标题】:Send asynchronous call in IOS 5在 IOS 5 中发送异步调用
【发布时间】:2012-06-12 19:23:41
【问题描述】:
如何向服务器发送 url 以在我的数据库中添加一些内容?
我在 ios 4 中使用 NSURLConnection 进行异步调用,但从 ios 5 开始,此方法不再存在。苹果说我应该使用:
sendAsynchronousRequest:queue:completionHandler:
但我不知道如何实现这一点,只向我的服务器发送一个 url 而对返回的数据不做任何事情?或者如何在 ios 5 中发送异步调用
提前致谢
【问题讨论】:
标签:
iphone
xcode
ios5
nsurlconnection
【解决方案1】:
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSLog(@"%@", data);
}];