2
votes

I am trying to send the data to server from my Iphone client. It works fine for most values but when itry to send a string like "IPhone+Cocoa" the server shows the string as "IPhone Cocoa". I have tried to google it but without success is there any why of doing it.

Here is my code

-(void)sendRequest:(NSString *)aRequest
{
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:kURLRequest]]; 
    NSString *httpBody =  [NSString stringWithFormat:@"%@=%@",[requestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[aRequest stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSData *aData = [httpBody dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:aData];
    [request setHTTPMethod:@"POST"];
    self.feedURLConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}

Can anyone help me?

1

1 Answers

0
votes

You do this for requestString and aRequest,but not after formatting together with your addition..

Try

httpBody = [httpBody stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

before

NSData *aData = [httpBody dataUsingEncoding:NSUTF8StringEncoding];