IOS AFNETWORKING POST

IOS AFNETWORKING POST 请求

        #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);
        }];
原文地址:https://www.cnblogs.com/duke-cui/p/4798709.html