• NSNull与nil


        NSDictionary *dictNull = @{@"key":[NSNull null]};

     

        NSDictionary *dictNil = @{@"key":nil};//Collection element of type 'void *' is not an Objective-C object

     

     

     

     

     

        NSMutableDictionary *dict = [NSMutableDictionary dictionary];

        [dict setValue:nil forKey:@"keyNil"];

        [dict setObject:[NSNull null] forKey:@"keyNull"];

    /* Send -setObject:forKey: to the receiver, unless the value is nil, in which case send -removeObjectForKey:.

    */

    - (void)setValue:(nullable ObjectType)value forKey:(NSString *)key;

     

     

    - (void)setObject:(ObjectType)anObject forKey:(id<NSCopying>)aKey;

    Important

    Raises an NSInvalidArgumentException if anObject is nil. If you need to represent a nil value in the dictionary, use NSNull.

  • 相关阅读:
    J
    I
    uva122 二叉树的实现和层次遍历(bfs)
    A
    HDU 波峰
    2239: 童年的圣诞树
    1734: 堆(DFS)
    1731: 矩阵(前缀和)
    1733: 旋转图像(模拟)
    1728: 社交网络(概率问题 组合数/排列数)
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/7903751.html
Copyright © 2020-2023  润新知