NSMutableDictionary *dic = [NSMutableDictionary new];

dic setValue:<#(nullable id)#> forKey:<#(nonnull NSString *)#>

dic setObject:<#(nonnull id)#> forKey:<#(nonnull id)#>

[NSNull null] An empty object

[dic setObject:[NSNull null] forKey:@(1)];

NULL NULL pointer

int *pointerToInt = NULL;

char *pointerToChar = NULL;

Nil empty class

Class someClass = Nil;

Nil Empty object of type ID

[dic setValue:nil forKey:@”nil”];

In the case where the server returns NULL

If ([STR isnull :[NSNull null]]) {

}
if ([str isKindOfClass:[NSNull class]]) {
    
}
Copy the code

Method 2:

Using the AFN AFJSONResponseSerializer an attribute to remove null values removesKeysWithNullValues = YES

Replace null with @ “”;