3

i am getting one url from the server http: / /www.google.com, however due to space in between them it is not opening, please let me know how to remove the space in between them, so that it should open in safari.

Eiko
  • 25,601
  • 15
  • 56
  • 71
user748001
  • 181
  • 6
  • 21

4 Answers4

9

To remove empty space:

str = [str stringByReplacingOccurrencesOfString:@" " withString:@""];

Use following to detect site or phone number in text view.

textview.dataDetectorTypes = UIDataDetectorTypeAll;
jigneshbrahmkhatri
  • 3,627
  • 2
  • 21
  • 33
1
NSString *cleanString = [dirtyString stringByReplacingOccurrencesOfString:@"http: //" withString:@"http://"];

I'd wonder why you get this odd string in the first place, though.

Eiko
  • 25,601
  • 15
  • 56
  • 71
1
NSString *str = @"hel lo";

[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
visakh7
  • 26,380
  • 8
  • 55
  • 69
Dileep Reghu
  • 879
  • 7
  • 6
0

For remove empty spaces, please use below code,

str = [str stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
Amar
  • 13,202
  • 7
  • 53
  • 71
Chris Alan
  • 1,426
  • 14
  • 14