agregando + antes de usar% 2b usando codificación url en iphone
Tengo una aplicación en la que, con un clic, estoy pasando el método de api de mi servidor que llama al método de publicación JSON y guarda los datos en la base de datos del servidor. Aquí guardo mi número de teléfono móvil y no de emergencia en la base de datos del servidor. .En mi variable de cadena de número de móvil, mi número de móvil se guarda, que está en este formato '+ 90-9491491411'. Estoy ingresando + y luego código y luego- y luego número, pero cuando lo envío a la base de datos del servidor estoy eliminando el - y enviar el no a la base de datos, pero el problema está en mi servidor La base de datos + del dispositivo móvil no se ingresa, por lo que estoy ingresando. Cuál puede ser el problema. Estoy usando el método POST para enviar la solicitud. Este es mi código
-(void)sendRequest
{
NSString *newstring = txtMobile.text;
mobileValue = [newstring stringByReplacingOccurrencesOfString:@"-" withString:@""];
NSLog(@"%@",mobileValue);
NSString *newString1 = txtemergencyprovider.text;
emergencyNumber = [newString1 stringByReplacingOccurrencesOfString:@"-" withString:@""];
NSLog(@"%@",emergencyNumber);
if ([txtEmail.text isEqualToString:@""])
{
post = [NSString stringWithFormat:@"CommandType=new&ApplicationType=%d&FullName=%@&Mobile=%@&EmergencymobileNumber=%@&Latitude=%f&Longitude=%f&City=%@&MobileModel=Apple",applicationtype,txtFullname.text,mobileValue,emergencyNumber,latitude,longitude,txtCity.text];
NSLog(@"%@",post);
}
else {
post = [NSString stringWithFormat:@"CommandType=new&ApplicationType=%d&FullName=%@&Mobile=%@&EmergencymobileNumber=%@&Latitude=%f&Longitude=%f&City=%@&EmailAddress=%@&MobileModel=Apple",applicationtype,txtFullname.text,mobileValue,emergencyNumber,latitude,longitude,txtCity.text,txtEmail.text];
NSLog(@"%@",post);
}
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"%@",postLength);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://myapi?RequestType=NEW"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
webData = [[NSMutableData data] retain];
NSLog(@"%@",webData);
}
else
{
}
}
// En mi número de móvil y en la variable de número de urgencia, mi no está en este formato '+91986444711', pero cuando el valor se ingresa en la base de datos del servidor + se elimina. Es posible que sea el problema.