網絡請求ASIhttp

#pragma mark 網絡請求
-(void)httpNetworkData
{
    NSString *str =@"http://115.29.177.74:8800/loose_change/login?";
    NSURL *url=[NSURL URLWithString:str];
    ASIFormDataRequest *request=[[ASIFormDataRequest alloc]initWithURL:url];
[request setPostValue:textFieldZH.text forKey:@"phone"]; [request setPostValue:textFieldMM.text forKey:@"pwd"]; request.delegate=self; request.timeOutSeconds = 30; [request setDidFinishSelector:@selector(requestNetworkData:)]; [request setDidFailSelector:@selector(GetErr:)]; [request startAsynchronous]; } -(void)requestNetworkData:(ASIHTTPRequest *)request { NSError *error=nil; NSData *data=[request responseData]; NSDictionary *jsonDic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error]; NSString *dic=[jsonDic objectForKey:@"response"]; }
-(void)GetErr:(ASIHTTPRequest *)request
{
    NSError *error = [request error];

    NSLog(@"Connection failed! Error - %@ %@",

          [error localizedDescription],

          [[error userInfo]objectForKey:NSUnderlyingErrorKey]);

}

  

 

網絡錯誤信息處理html

http://bbs.9ria.com/thread-242604-1-1.htmljson

 

發2個基於ASIHttpRequest的多任務異步網絡傳輸類  http://blog.csdn.net/watsy/article/details/8201086網絡

開源中國iOS客戶端學習——(五)網絡通訊ASI類庫(1)異步

相關文章
相關標籤/搜索