検索しましたが、問題を解決できません。ここで、データをサーバーに投稿します。ユーザーのデフォルト、テキストビュー、テキストフィールドが 1 つあります。これから助けてください。
NSUserDefaults *getting= [NSUserDefaults standardUserDefaults] ;
userID1=[getting objectForKey:@"uId"];
NSString *bodyString=[NSString stringWithFormat:@"userId=%@&question=%@&categoryId=%@",userID1,askTextViewObj.text,specialistField.text];
[bodyString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",bodyString);
request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"XXXXXXXXXXXXXXXXXX" ] cachePolicy:0 timeoutInterval:30];
[request setHTTPMethod:@"POST"];
[request setHTTPShouldHandleCookies:YES];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPBody:[bodyString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]];
[request addValue:[NSString stringWithFormat:@"%d", [bodyString length]] forHTTPHeaderField:@"content-Length"];
connection=[NSURLConnection connectionWithRequest:request delegate:self ];
if (!connection)
{
UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Failed to Connect Server " delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
[aler show];
}
else
{
NSLog(@"Connection is Successfully");
}