iOS中Get请求带中文参数的编码问题

*近测试为了方便直接使用get接收参数,但是在iOS中使用的时候,get中的中文参数却存在乱码问题,需要转换以下才可以使用:

NSString * unicodeStr = [@”yourParam” stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString * url = [NSString stringWithFormat:@”%@?testparam=%@”,@”https://api.yoururl.com/test”,unicodeStr];