gpt4 book ai didi

ios - 我们如何在 NSstring ios 中存储一堆 json 键值

转载 作者:行者123 更新时间:2023-11-29 12:04:33 25 4
gpt4 key购买 nike

  source =   {
Address1 = "3244 W WASHINGTON ST , ";
Address2 = "";
City = "ANDERSON ";
Name = "<null>";
PhoneNo = "<null>";
ProviderId = "<null>";
ProviderName = "<null>";
State = IN;
Zip = "46011-";
};

嗨,我是 ios 的新手,我正在将我的应用程序与服务集成,在收到服务的响应后,我存储了上面的字典值,如下面的代码,但它显示异常

请帮助我如何在一个 NSstring 中存储以上 kay 值

我的代码:-

 NSString *SourceAdrees = [NSString stringWithFormat:@"%@\n %@ %@ %@" ,[[[[[dicCurrentIndex valueForKeyPath:@"source"]valueForKey:@"Address1"]valueForKey:@"City"]valueForKey:@"State"]valueForKey:@"Zip"]];

NSLog(@"SourceAdrees is %@",SourceAdrees);

最佳答案

如果我明白你想做什么,代码应该是这样的:

NSDictionary *sourceDict = dicCurrentIndex[@"source"];
NSString *sourceAddress = [NSString stringWithFormat:@"%@\n %@ %@ %@",
sourceDict[@"Address1"],
sourceDict[@"City"],
sourceDict[@"State"],
sourceDict[@"Zip"] ];

(变量名要以小写字母开头,单词是“address”,不是“SourceAdrees”)

关于ios - 我们如何在 NSstring ios 中存储一堆 json 键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35523755/

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