Reputation: 181
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.
Upvotes: 3
Views: 6654
Reputation: 1426
For remove empty spaces, please use below code,
str = [str stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
Upvotes: 0
Reputation: 879
NSString *str = @"hel lo";
[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
Upvotes: 1
Reputation: 3637
To remove empty space:
str = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
Use following to detect site or phone number in text view.
textview.dataDetectorTypes = UIDataDetectorTypeAll;
Upvotes: 9
Reputation: 25632
NSString *cleanString = [dirtyString stringByReplacingOccurrencesOfString:@"http: //" withString:@"http://"];
I'd wonder why you get this odd string in the first place, though.
Upvotes: 1