¿Cómo elimino cierto texto de NSString
como "http: //"? Necesita ser exactamente en ese orden. ¡Gracias por tu ayuda!Eliminar http: // de NSString
Aquí está el código que estoy usando, sin embargo, el http: // no se elimina. En cambio, aparece http://http://www.example.com. ¿Que debería hacer? ¡Gracias!
NSString *urlAddress = addressBar.text;
[urlAddress stringByReplacingOccurrencesOfString:@"http://" withString:@""];
urlAddress = [NSString stringWithFormat:@"http://%@", addressBar.text];
NSLog(@"The user requested this host name: %@", urlAddress);
Está añadiendo de nuevo la misma cadena. No es necesario utilizar la tercera línea si desea eliminar http: // – Nitish
Si el usuario no ingresa http: //, entonces UIWebView funcionará. Sin embargo, si el usuario ingresa http: //, entonces UIWebView no funcionará. Al eliminar cualquier http: // que haya y luego reinsertarlo una vez, se me garantiza que NSString se verá así: http: // www.google.com –
posible duplicación de [Eliminar parte de un NSString] (http://stackoverflow.com/questions/4423248/remove-part-of-an-nsstring) –