2016-08-01 2 views

答えて

0

URLにパスがない場合は、文字列の末尾に.egを追加するだけです。

NSString *newCountryString = [[url absoluteString] stringByAppendingString:@".eg"]; 

NSURL *newCountryUrl = [NSURL URLWithString:newCountryString]; 

URLはこれを行うパスを持っている場合:

NSString *host = [url host]; 
NSString *domain = [[host componentsSeparatedByString:@"."] lastObject]; 
NSString *newCountryString = [[url absoluteString] stringByReplacingOccurrencesOfString:domain withString:[domain stringByAppendingString:@".eg"]]; 
NSURL *newCountryUrl = [NSURL URLWithString:newCountryString]; 
+0

を私はのような任意のゾーンに追加したい「例えば」特定追加したくない「英国を...」 – MOMMH

+0

例えばましたほんの一例です言語設定で場所を取得する場合は、次のようにします。NSString * countryCode = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];物理的な場所でこの投稿をチェックしたい場合は、http://stackoverflow.com/questions/8534496/get-device-location-only-country-in-ios – lopes710

関連する問題