ios - Could [NSMutableArray array] return nil? -
for example in low memory conditions. i'm reading third party code , saw this
nsmutablearray *array = [nsmutablearray array]; if (array != nil) { [array addobject:anobject]; } i've never check after creating array way nor alloc+init i'm in doubt.
technically, could return nil.
the probability of such failure @ point incredibly unlikely. app crash or abort before nil returned. consider unlikely malloc returning null.
my implementations have used checked object creation years - cannot remember ever seeing [nsmutablearray array] return nil in time in development/testing.
note answer specific [nsmutablearray array], not any/every initializer/constructor in existence. [nsmutablearray array] 'consistent' class of initializer/constructor in regard because there no reason fail under normal circumstances.
Comments
Post a Comment