我需要通过帖子请求将此SomeString发送到服务器。
没有使它成为NSData
对象并且NSUTF8StringEncoding
SetHttpBody:只问我一个NSData对象。
我该如何发布这个字符串
SomeString = @"registerRecipt.aspx?udid=962c3486-a8d6-4c32-9ff8-7b255cce4d65&receipt=ewoJInNpZ25hdHVyZSIgPSAiQW1wMnhiVGxYTGg5UmhFUUlCMzNLMHdZdHl3Tnd0WWFVaEdKQzNoUE04Rm8wSys4NE5wWkdWdWRFRndjQ0k3Q2draVluWnljeUlnUFNBaU1TNHdJanNLZlE9PSI7CgkiZW52aXJvbm1lbnQiID0gIlNhbmRib3giOwoJInBvZCIgPSAiMTAwIjsKCSJzaWduaW5nLXN0YXR1cyIgPSAiMCI7Cn0="
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://someUrl.com/"]];
request.timeoutInterval = 20;
[request setHTTPMethod:@"POST"];
[request setHTTPBody:SomeString];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
答案 0 :(得分:2)
您可以使用[SomeString dataUsingEncoding:NSUTF8StringEncoding];
答案 1 :(得分:0)