Let's say I have www.GOOgle.com/.......
I want to change it to www.google.com/....
and keep the rest of url as it is.
I have tried with NSURLComponents
, but it didn't work.
// I am taking input from textfield and making the nsurl.
NSURLComponents *components = [NSURLComponents componentsWithString: _textfield.text]; // input from textfield
[[components host] lowercaseString];
NSURL *urlin = [components URL]; //but this gives, www.GOOgle.com
Any lead is appreciated.
As @Larme Suggests you can use method to setHost in url
see below example
NSURLComponents *components = [NSURLComponents componentsWithString: @"https://sTackoverFlow.com/questions/47924276/how-to-convert-host-of-nsurl-to-lowercase"];
[components setHost:[components.host lowercaseString] ];
NSLog(@"%@",components.URL)
H ttps://stackoverflow.com/questions/47924276/how-to-convert-host-of-nsurl-to-lowercase
NOTE:
http:// is required to add in String otherwise you will get host nil eg https://www.sTackoverFlow.com/questions/47924276/how-to-convert-host-of-nsurl-to-lowercase it will work
while
www.sTackoverFlow.com/questions/47924276/how-to-convert-host-of-nsurl-to-lowercase