You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.2 KiB
71 lines
2.2 KiB
10 years ago
|
/*
|
||
|
* Copyright (c) 2014 - Facebook.
|
||
|
* All rights reserved.
|
||
|
*/
|
||
|
|
||
|
#import <Foundation/Foundation.h>
|
||
|
|
||
|
|
||
|
void update_dict_with_null() {
|
||
|
NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||
|
@"Matt", @"firstName", @"Galloway", @"lastName",
|
||
|
@28, @"age", nil];
|
||
|
mDict[@"firstName"] = nil;
|
||
|
}
|
||
|
|
||
|
void update_dict_with_key_null() {
|
||
|
NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||
|
@"Matt", @"firstName", @"Galloway", @"lastName",
|
||
|
@28, @"age", nil];
|
||
|
id key = nil;
|
||
|
mDict[key] = @"Dulma";
|
||
|
}
|
||
|
|
||
|
void update_dict_without_null() {
|
||
|
NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||
|
@"Matt", @"firstName", @"Galloway", @"lastName",
|
||
|
@28, @"age", nil];
|
||
|
mDict[@"firstName"] = @"Dulma";
|
||
|
}
|
||
|
|
||
|
void update_array_with_null() {
|
||
|
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil];
|
||
|
NSUInteger idx = 0;
|
||
|
id newObject = nil;
|
||
|
array[idx] = newObject;
|
||
|
}
|
||
|
|
||
|
void update_array_without_null() {
|
||
|
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil];
|
||
|
NSUInteger idx = 0;
|
||
|
id newObject = @"Dino";
|
||
|
array[idx] = newObject;
|
||
|
}
|
||
|
|
||
|
void add_nil_to_array() {
|
||
|
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil];
|
||
|
id str = nil;
|
||
|
[array addObject:str];
|
||
|
}
|
||
|
|
||
|
void insert_nil_in_array() {
|
||
|
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil];
|
||
|
id str = nil;
|
||
|
[array insertObject:str atIndex:0];
|
||
|
}
|
||
|
|
||
|
void add_nil_in_dict() {
|
||
|
NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||
|
@"Matt", @"firstName", @"Galloway", @"lastName",
|
||
|
@28, @"age", nil];
|
||
|
id str = nil;
|
||
|
[mDict setObject:str forKey:@"firstName"];
|
||
|
}
|
||
|
|
||
|
void no_npe_for_undef_values (NSDictionary* response){
|
||
|
NSMutableDictionary *fileInfo = [response mutableCopy];
|
||
|
fileInfo[@"type"] = @"BLA";
|
||
|
NSMutableDictionary *d = [NSMutableDictionary dictionary];
|
||
|
d[@"fds"] = fileInfo;
|
||
|
}
|