这是我的代码
for(id tempLangItem in jp.staffData)
{
NSMutableDictionary *temp=[[NSMutableDictionary alloc] initWithDictionary:tempLangItem];
NSString *name = [temp objectForKey:@"lang_name"];
NSLog(@"item_name =%@",name);
NSLog(@"value in dictionary=%@",temp);
}
这些是日志详情
item_name =marinieres
value_in_dictionary={
"lang_id" = 2;
"lang_name" = "\U7a46\U840a\U65afmarinieres";
time = "2013-06-05 05:14:50";
}
为什么lang_name=\U7a46\U840a\U65afmarinieres
日志在value_in_dictionary
日志中显示正确时,为item_name
提供{{1}}。
答案 0 :(得分:2)
尝试
NSMutableDictionary *temp=[[NSMutableDictionary alloc]init];
[temp setObject:@"marinieres" forKey:@"lang_name"];
NSString *name = [temp objectForKey:@"lang_name"];
NSLog(@"item_name =%@",name);
NSLog(@"value in dictionary=%@",temp);
以及我的日志显示
2013-06-06 12:38:02.337 Cool[96423:11303] item_name =marinieres
2013-06-06 12:38:04.022 Cool[96423:11303] value in dictionary={
"lang_name" = marinieres;
}
1快速问题:如果是NSDictionary,为什么要创建新实例?
NSMutableDictionary *temp=[[NSMutableDictionary alloc] initWithDictionary:tempLangItem];
尝试使用tempLangItem