如果其他代码检查,这是编写此代码的最佳方法吗?
// set the default to Italy if countrySaved is null
if (lang == NULL) {
lang = @"it";
}
// otherwise set the correct lang based on the country chosed and saved in nsuserdefaults
if ([countrySaved isEqual:@"Brazil"]) {
lang = @"br";
}
else if ([countrySaved isEqual:@"Spain"]) {
lang = @"es";
}
else if ([countrySaved isEqual:@"Italy"]) {
lang = @"it";
}
else if ([countrySaved isEqual:@"United States"]) {
lang = @"us";
}
else if ([countrySaved isEqual:@"United Kingdom"]) {
lang = @"uk";
}
谢谢你的帮助