gpt4 book ai didi

ios - 字典给出不正确的值

转载 作者:行者123 更新时间:2023-11-28 22:32:46 25 4
gpt4 key购买 nike

这是我的代码

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";
}

为什么它在 value_in_dictionary 日志中给出 lang_name=\U7a46\U840a\U65afmarinieres 而它在 item_name 日志中显示正确。

最佳答案

尝试过

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

关于ios - 字典给出不正确的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16955655/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com