iphone - 如何从 nsmutabledictionary 中删除键当该键的值在 ios 中为空或 null 时?

标签 iphone ios nsmutabledictionary

我已经创建了 NSMutableDictionary,键的值形成为 nsarray。我已经删除了键的对象。我对这个案子毫无疑问。但是我想在该键的值为空或 null 时删除键,如下所示。

{
    Africa =     (
        "Kenya",
        "South Africa"
    );
    America =     (
    );
    Asia =     (
        "India"
    );
}

上面的字典有三个键,其中一个键没有对象是 America。我想删除这把 key 。可能吗? 我们可以从 nsmutabledictionary 中删除键吗?

请帮帮我......

已编辑:简单的错误。我明白我弄错了什么。 key(America) 有值,它是空数组,这意味着数组中的元素数为零。

最佳答案

The above dictionary has three keys and one of these keys has no objects that is America.

假的。它包含一个空的 NSArray。这是删除它的方式:

[dictionary removeObjectForKey:@"America"];

关于iphone - 如何从 nsmutabledictionary 中删除键当该键的值在 ios 中为空或 null 时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14577428/

相关文章:

iphone - 如何在 iPad 中自动旋转期间重新排列 View

ios - 发送到不可变对象(immutable对象)的变异方法

ios - 在for循环中将NSDictionary转换为NSMutableDictionary

ios - 按月份对 NSDictionary 的值进行分组和求和,其中键为 NSDate

iphone - NSMutableDictionary 的 JSONRepresentation

iphone - 捏合手势和两个图像缩放

iphone - iOS 模拟器是否使用多核?

c++ - 在 cpp 中调用方法,如 @selector(someMethod :) in Objective-C

ios - 如何使用 Swift 5 的代理配置连接到 HTTP 服务器(为什么忽略 connectionProxyDictionary)?

ios - 如何在不卡住 ARSession 的情况下将 ARSCNView 放入 Tabview Controller 中?