objective-c - 如何在字典中写入属性数组
问题描述
我需要在数组里面输入一个属性值怎么办??
我试图在字典中显式添加数组
NSDictionary *uilabeldropdown = @{
@"UILabelDropDownWithTextField" : @{
@"headingLabel" : @{
@"localizationKey" : @"Number"
},
@"userTextField" : @{
@"xpath" : @"Home"
},
@"contentArray" : @[
@"item 0":@"Home",
@"item 1":@"New",
@"item 2":@"ground"
]
}
};
解决方案
@[...]
是 an 的语法NSArray
,它不支持字符串键。
@"contentArray" : @[
@"item 0":@"Home",
@"item 1":@"New",
@"item 2":@"ground"
]
删除键并按索引访问值。
@"contentArray" : @[
@"Home",
@"New",
@"ground"
]
uilabeldropdown[@"contentArray"][0]
推荐阅读
- java - 有没有办法在运行时忽略杰克逊字段而不使用@JsonIgnore
- kotlin - 是否有相当于 ?: java 运算符的 kotlin?
- javascript - Javascript:无法复制数组并使它们保持独立
- python - 替代标准差来表示信号的躁动
- c++ - 在 C++ 中使用具有默认模板参数的模板类时出现“模板参数太少错误”
- android - 如何使用动态内容构建两个同步 ListView
- python - 在 Discord.py 中 - 重写 AttributeError:'Bot' 对象没有属性 'voice_client_in'
- c# - 移除系统窗口的焦点
- mongodb - Mongoose TypeError:无法读取 null 的属性“insertOne”
- reactjs - React Jest setInterval 测试覆盖率