我有一個用於post方法的字符串。如果字符串像"hello.."
比值傳遞方法。但是如果字符串比"hello world"
比不採取郵寄方式。如果我在字符串中使用空格,那麼它不起作用。請幫助我。如何在字符串ios中添加空白空間
- (void) constructURL
{
NSMutableString* curl = [[NSMutableString alloc] init];
[curl appendString:@"XXXXX"];
[curl appendString:[NSString stringWithFormat:@"?eventid=%@", eventID]];
[curl appendString:[NSString stringWithFormat:@"&ForumID=%@", forumID]];
[curl appendString:[NSString stringWithFormat:@"&parentPostID=%@", parentPostID]];
[curl appendString:[NSString stringWithFormat:@"&userid=%@", userID]];
[curl appendString:[NSString stringWithFormat:@"&PostContent=%@", postContent]];
url = [NSURL URLWithString:curl];
}
使用stringByAddingPercentEscapesUsingEncoding上的[無法創建有效的NSURL]串 – the1pawan
可能重複(http://stackoverflow.com/questions/ 4637799/not-able-to-create-valid-nsurl) – Larme