URL写得正确,我在浏览器中用数据测试它并且它正确发送,但是当我发出请求时,它返回它成功,但它实际上并没有写入数据。有什么想法吗?
- (void)writeAboutMe:(NSString *)about withIcebreaker:(NSString *)icebreaker
{
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
NSString *urlString = [NSString stringWithFormat:@"http://nailorbail.net63.net/submit_about_and_icebreaker.php?username=%@&about=%@&icebreaker=%@",[SignInViewController getUsernameString] ,about,icebreaker];
NSLog(@"%@",urlString);
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(conn)
NSLog(@"Connection Successful");
else
NSLog(@"Connection could not be made");
[conn release];
}
答案 0 :(得分:1)
答案 1 :(得分:1)
这可能是编码问题。 getUsernameString
,about
和icebreaker
中包含哪些字符?正如Maudicus所说,你需要自己处理URL中的特殊字符。
尝试:
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]