IOS AFNETWORKING POST

时间:2025-01-10 11:36:20

IOS AFNETWORKING POST 请求

        #pragma mark post 请求
// 获取 url 路劲,不带参数
NSString *requestUrl = [[url componentsSeparatedByString:@"?"] objectAtIndex:]; // url参数截取
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:];
NSArray *parameArray = [[[url componentsSeparatedByString:@"?"] objectAtIndex:] componentsSeparatedByString:@"&"]; for (int i = ; i < [parameArray count]; i++) { NSString *key = [[[parameArray objectAtIndex:i] componentsSeparatedByString:@"="] objectAtIndex:];
NSString *value = [[[parameArray objectAtIndex:i] componentsSeparatedByString:@"="] objectAtIndex:]; [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);
}];