gpt4 book ai didi

ios - 向 nsdictionary 添加各种对象和键

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:50 26 4
gpt4 key购买 nike

<分区>

我想用对象和键创建一个 NSDictionary,如下例所示

NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", nil];
NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects
forKeys:keys];

但我需要添加多个寄存器,例如:

code=1
description=John

code=2
description=Paul

code=3
description=Peter
.
.
.

exactly what I need, an NSDictionary like a json structure:
{
"people": [
{ "code":"1" , "name":"John" },
{ "code":"2" , "name":"Smith" },
{ "code":"3" , "name":"Jones" }
]
}

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