Codificación de espacios en UITextView / UITextField a formato URL
Estoy tratando de enviar el contenido de UITextView o UITextField como parámetros a un archivo php
NSString *urlstr = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@",nameField.text, tagsField.text, dreamEntry.text];
Cuando registro urlstr, el formato de url está bien siempre que UITextView o UITextField no contengan espacios. ¿Cómo haría para convertir los espacios a% 20?
edita
Aquí está el código, que no solo se bloquea sino que no codifica la URL correctamente.
name = John Doe & tags = pesadilla recurrente & entry = Pruebas pruebas pruebas
se convierte en
name = John -1844684964oe & tags = recurringightmare & entry = Prueba 4.214929e-307sting -1.992836e + 00sting
- (IBAction)sendButtonPressed:(id)sender
{
NSString *urlString = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@", nameField.text, tagsField.text, dreamEntry.text];
NSString *encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:encodedString];
NSLog(encodedString);
NSLog(urlString);
[urlString release];
[url release];
[encodedString release];
}