首页 > 代码库 > MKNetWorkKit打印URL
MKNetWorkKit打印URL
-(void)initNewUrl:(NSString *)urlString param:(NSMutableDictionary *)_paramDic{
//拼接参数至URL
NSMutableString *paramsStr = [[NSMutableString alloc] initWithString@“”];
if(_paramDic!=nil && [_paramDic cout] >0)
{
NSEnumerator * enumerator = [_paramDic keyEnumerator];
id key;
int c = 0;
while(key = [enumerator nextObject]){
if(c !=0){
[paramStr appendString:@“&”];
}
[paramStr appendFormat:@“%@=%@”,key,[_paramDic objectForKey:key]];
c++;
}
}
NSMutableString *newUrl = [[NSMutableString alloc] initWithString:urlString];
if(paramsStr != nil && [paramsStr length] >0){
NSRange range;
range = [newUrl rangOfString:@“?”];
if(range.length!=0){
[newUrl appendFormat:@“&%@”,paramsStr];
}else{
[newUrl appendFormat:@“?%@”,paramsStr];
}
}
NSLog(@“newUrl=%@”,newUrl);
}