An empty array is returned.
An example implementation +arrayWithArray:will be as follows:
+(id) arrayWithArray:(NSArray *) arr
{
NSMutableArray *returnValue = [NSMutableArray new];
returnValue->objectsCount = [arr count];
returnValue->objectsPtr = malloc(sizeof(id) * returnValue->objectsCount);
[arr getObjects:returnValue->objectsPtr range:NSMakeRange(0, returnValue->objectsCount)];
return returnValue;
}
Thus, if it arris null, it -countreturns 0, there is nothing malloc'd, and nothing is copied, since the message sent to the nil object returns the default value for this type and does nothing.
source
share