一、 [NSURL URLWithString:urlString],urlString的类型必须正确,必须以http或者https开头,在一次项目中由于在http前面多了个空格,致使字符串转化为NSURL类型时为空。 安全
二、在使用ASI发送请求时,相同信息能够放在http头部统一处理,这样就能够在每次请求中加入相同的参数 app
三、使用 [NSURL URLWithString:urlString]致使返回的url为nil,由于 测试
Return Value An NSURL object initialized with URLString. If the string was malformed, returns nil. Discussion This method expects URLString to contain any necessary percent escape codes, which are ‘:’, ‘/’, ‘%’, ‘#’, ‘;’, and ‘@’. Note that ‘%’ escapes are translated via UTF-8.因此使用
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //经过utf-8编码,来规避一些特殊字符 url = [NSURL URLWithString:urlStr];
四、使request在后台持续运行,直到回调完成 编码
ASIHTTPRequest supports running requests in the background: url
[request setShouldContinueWhenAppEntersBackground:YES];五、禁用安全证书校验
在用https链接时可能会使用到 ,若是你有一个自签名的证书,你可能想禁用证书校验来作测试。这里我建议你从一个可信的CA购买证书,并为生产(production)期的app启用证书校验。 spa
[request setValidatesSecureCertificate:NO];(转自: http://blog.csdn.net/yhawaii/article/details/7910483)