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);

}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

上一篇:iOS开发网络篇—网络请求(HTTP协议)小结


下一篇:C语言基础04