0

這可能是簡單的,我只是俯瞰。我正在嘗試使用AFNetworking從uStream的API中創建一個AFHTTPRequest。我應該得到一個JSON有效負載響應,它列出了uStream頻道上的所有視頻。這裏是我的代碼:AFNetworking與UStream頻道的視頻列表API請求

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

我複製並粘貼了你的代碼,它對我很好。 – Sandeep 2015-01-26 22:05:50

+0

你回覆什麼? – DJSK 2015-01-26 22:12:50

+1

我得到了相同的json響應。 – Sandeep 2015-01-26 22:13:17

回答

0

我的代碼很好,但是我的iphone模擬器出現了問題。重置內容和設置的竅門。感謝k6sandeep的幫助。