AFNetWorking 圖片本地緩存的問題html
http://www.cnblogs.com/Wendale-Zhang/archive/2013/01/17/2864442.htmljson
今天看了下AFNetwoking這個通信庫,簡單研究了一下緩存
(1)POST請求app
//創建URLpost
NSURL* url = [NSURL URLWithString:@"XXXX"];編碼
//表單數據url
NSDictionary* requestDict = [NSDictionarydictionaryWithObjectsAndKeys:themeId,@"themeId", nil];spa
//創建POST請求orm
AFHTTPClient *aClient = [AFHTTPClient clientWithBaseURL:url];htm
//設置接受的數據類型爲json
[aClient setDefaultHeader:@"Accept"value:@"application/json"];
//設置提交的數據編碼類型爲json格式
[aClient setParameterEncoding:AFFormURLParameterEncoding];
//開始請求
[aClient postPath:nil parameters:requestDictsuccess:^(AFHTTPRequestOperation*operation,id responseObject)
{
//解析數據
NSDictionary* Jsondict = [self parserJson:responseObject];
NSLog(@"%@",Jsondict);
}
failure:^(AFHTTPRequestOperation *operation,NSError *error)
{
}];
(2)GET請求
//創建URL
NSURL* url = [NSURL URLWithString:@"XXXX"];
//創建請求
AFHTTPClient *bClient = [AFHTTPClient clientWithBaseURL:url];
//開始請求
[bClientgetPath:nil parameters:nil success:^(AFHTTPRequestOperation *operation,id responseObject)
{
NSLog(@"response description:%@", [responseObjectdescription]);
}
failure:^(AFHTTPRequestOperation *operation,NSError *error)
{
NSLog(@"error description:%@",[error description]);
}];