我有像这样的NSDictionary
NSDictionary *result = [[NSDictionary alloc]
initWithObjectsAndKeys:
@"USA.png", @"США",
@"EC.png", @"ЕС",
@"Russia.png", @"Россия",
@"Brazil.png", @"Бразилия",
....... and more ......
nil];
我希望通过从XML解析器发送字符串键eventCountry来获取此字典中的值。
NSString *countryImageString = [self.countrySet objectForKey:event.eventCountry];
if (countryImageString.length == 0) {
calCell.countryImageView.image = [UIImage imageNamed:@"Unknown.png"];
} else {
calCell.countryImageView.image = [UIImage imageNamed:countryImageString];
}
在NSLog中,我的NSDictionary看起来像
"\U0410\U0432\U0441\U0442\U0440\U0430\U043b\U0438\U044f" = "Australia.png";
"\U0410\U0432\U0441\U0442\U0440\U0438\U044f" = "Austria.png";
"\U0410\U043d\U0433\U043b\U0438\U044f" = "England.png";
"\U0410\U0440\U0433\U0435\U043d\U0442\U0438\U043d\U0430" = "Argentina.png";
"\U0411\U0435\U043b\U044c\U0433\U0438\U044f" = "Belgium.png";
"\U0411\U0440\U0430\U0437\U0438\U043b\U0438\U044f" = "Brazil.png";
但eventCountry是UTF-8。如何在没有\ U0410 \ U0432 \字符的情况下正确填写plist文件或动态转换编码?
答案 0 :(得分:0)
这只是你的字典或数组的description
方法(NSLog()
用于打印对象)愚蠢且无益地转义文本。写入文件时字符串将是正确的。