ios - convert Nsurl Domain to my country domain -


how convert nsurl domain country domain

example :

nsurl *url = [nsurl urlwithstring:@"http://www.google.com"]; 

how can thing http://www.google.com.eg

it can detect zone , change domain zone, if website support multi zones domain.

if there isn't path in url append .eg end of string.

nsstring *newcountrystring = [[url absolutestring] stringbyappendingstring:@".eg"];  nsurl *newcountryurl = [nsurl urlwithstring:newcountrystring]; 

if url has path this:

nsstring *host = [url host]; nsstring *domain = [[host componentsseparatedbystring:@"."] lastobject]; nsstring *newcountrystring = [[url absolutestring] stringbyreplacingoccurrencesofstring:domain withstring:[domain stringbyappendingstring:@".eg"]]; nsurl *newcountryurl = [nsurl urlwithstring:newcountrystring]; 

Comments