NSArray and NSMutableArray's +arrayWithArray: returns empty array instead of nil when argument is nil.
NSLog(@"%@", [[NSArray arrayWithArray:nil] class]);
NSLog(@"%@", [[NSMutableArray arrayWithArray:nil] class]);
output:
__NSArrayI
__NSArrayM
But this behavior is not documented on Apples documentation.
Is it safe to rely on the assumption that arrayWithArray:nil returns empty array?
Or should I assign empty array explicitly like this:
NSDictionary *dic = [[NSDictionary alloc] init];
NSMutableArray *arr = [dic objectForKey:@"a"];
if (!arr) {
arr = [[NSMutableArray alloc] init];
}