ASIHttpRequest框架使用

要使用ASIRequest必须添加5个动态库,CFNetwork.framework、SystemConfigureation.framework、MobileCoreServices.framework、libz.dylib和libxml2.dylib

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setRequestMethod:@"GET"];
    [request setTimeOutSeconds:60];
    // 设置请求头
    // [request setRequestHeaders:<#(NSMutableDictionary *)#>]
    // 设置cookies
    // [request setRequestCookies:<#(NSMutableArray *)#>]
    // 发送同步请求
    [request startSynchronous];
    NSError *error = request.error;
    if (error == nil) {
        NSData *data = request.responseData;
        UIImage  *img = [UIImage imageWithData:data];
        NSLog(@"%@", data);
        self.image = img;
    } else {
        NSLog(@"请求网络出错:%@", error);
    }

如果出现编译出错

请看:http://blog.csdn.net/nono_love_lilith/article/details/7755087

ASIHTTPRequest 支持 ARC

http://www.cnblogs.com/buro79xxd/archive/2012/03/11/2390761.html

你可能感兴趣的:(ASIHTTPRequest)