HTTPS请求 - 在iOS上获取文档

时间:2012-10-01 09:07:41

标签: ios httprequest

我有文档链接(例如:https://example.com/test/test.pdf)。我曾尝试使用ASIHTTPRequest,但它不起作用。我知道我可以使用NSURL来获取它,但还有另一种方式或框架吗?

3 个答案:

答案 0 :(得分:0)

您无法仅使用NSURL获取文档内容,NSURL是网址的代表,您必须执行请求。

此处的一些元素:iPhone SDK: How do you download video files to the Document Directory and then play them?

答案 1 :(得分:0)

你应该在这里使用NSURLConnection。 See documentation on it.

答案 2 :(得分:0)

以下是如何处理STHTTPRequest https://github.com/nst/STHTTPRequest

__block STHTTPRequest *r = [STHTTPRequest requestWithURLString:@"https://example.com/test/test.pdf"];

r.completionBlock = ^(NSDictionary *headers, NSString *body) {
    NSData *pdfData = r.responseData;
};

r.errorBlock = ^(NSError *error) {
    //
};

[r startAsynchronous];