AFNetworking问题与UStream API请求频道的视频列表

时间:2015-01-26 21:51:50

标签: ios afnetworking afnetworking-2 afhttprequestoperation nsurlerrordomain

这可能是我想要忽视的简单事情。我正在尝试使用AFNetworking从uStream的API创建AFHTTPRequest。我应该获得一个JSON有效负载响应,列出uStream频道上的所有视频。这是我的代码:

NSURL *url = [NSURL URLWithString:@"https://api.ustream.tv/channels/12321320/videos.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"success");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"failed");
}];

[operation start];

在浏览器中测试时,一切正常,但在尝试使用AFNetworking时,我遇到了NSURLErrorDomain故障。有人有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我的代码很好但我的iphone模拟器出了问题。重置内容和设置就行了。感谢k6sandeep的帮助。