If I want to return an immutable array like this + (NSArray *)ids
but inside this method I'm declaring a NSMutableArray
because I want to sort it using -sortUsingSelector:
.
Returning this method works perfect.
But is it "okay" to write code that declares that the return method should be one type and the actually type is another?
Does this work because
NSMutableArray
is a subclass ofNSArray
?Is the actual return value an
NSArray
or anNSMutableArray
?