复制没有空值的 NSDictionary?
我正在尝试使用 dictionaryWithDictionary
方法创建一个 NSDictionary
。但是,我的第一个 NSDictionary A 可能有一些带有空值的键。如何创建没有任何带空值的键的 B?我做所有这些都是为了用与 NSDictionary
中每个非空键对应的行填充 UITableView
。
I'm trying to create an NSDictionary
with the dictionaryWithDictionary
method. However, my first NSDictionary
A may have some keys with empty values. How can I create B that doesn't have any keys with empty values? I'm doing all of this for the purposes of populating a UITableView
with rows that correspond to each non-empty key in the NSDictionary
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的事情怎么样:
How about something like this:
您还可以使用块测试,过滤掉其值具有长度的键,并从中创建新的字典。
You could also use a block test, filtering out the keys whose values have a length and create your new dictionary from that.