1.先去空格
NSString *urlString = @"http://sfsdfsdfsd sdfsdfsfsdf你好";
urlString = [urlString stringByReplacingOccurrencesOfString:@" "withString:@""];
2.转码
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
3.转成NSUrl
NSURL*url = [NSURL URLWithString:urlString];
网友评论