views:

551

answers:

1

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.

A: 

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];
Prakash
I tried it but without success. But when i pass the same request through browser to server it Works.
Ansh
ok..crude idea.. how abt having %3D instead of '=' ??
Prakash
Its crashing... I think because it treat %3D as a format specifier but i used backslash for it..but this also didin't worked. Any idea..........How it can be done... Thanks For Replying
Ansh