码迷,mamicode.com
首页 > 移动开发 > 详细

IOS AFNETWORKING POST

时间:2015-09-10 19:03:16      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

        #pragma mark post 请求
        // 获取 url 路劲,不带参数
        NSString *requestUrl = [[url componentsSeparatedByString:@"?"] objectAtIndex:0];
        
        // url参数截取
        NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:10];
        NSArray *parameArray = [[[url componentsSeparatedByString:@"?"] objectAtIndex:1] componentsSeparatedByString:@"&"];
        
        for (int i = 0; i < [parameArray count]; i++) {
            
            NSString *key = [[[parameArray objectAtIndex:i] componentsSeparatedByString:@"="] objectAtIndex:0];
            NSString *value = [[[parameArray objectAtIndex:i] componentsSeparatedByString:@"="] objectAtIndex:1];
            
            [dic setObject:value forKey:key];
        }
        
        AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
        
        [manager POST:requestUrl parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
            
            NSString *html = operation.responseString;
            
            NSString *js = [NSString stringWithFormat:@"%@(%@);",method,html];
            [self.webView stringByEvaluatingJavaScriptFromString:js];
            
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            
            
            NSLog(@"AFHTTPRequestOperationManager:发生错误!%@",error);
        }];

IOS AFNETWORKING POST

标签:

原文地址:http://www.cnblogs.com/duke-cui/p/4798709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!