title: How careful are you with your return types in Objective-C?
body: <p>Say you have a method that returns a newly generated NSArray instance that is built internally with an NSMutableArray. Do you always do something like this:</p>
  
  <pre><code>- (NSArray *)someArray {
      NSMutableArray *mutableArray = [[NSMutableArray new] autorelease];
      // do stuff...
      return [NSArray arrayWithArray:mutableArray];  // .. or [[mutableArray copy] autorelease]
  }
  </code></pre>
  
  <p>Or do you just leave the mutable array object as-is and return it directly because NSMutableArray is a subclass of NSArray:</p>
  
  <pre><code>- (NSArray *)someArray {
      NSMutableArray *mutableArray = [[NSMutableArray new] autorelease];
      // do stuff...
      return mutableArray;
  }
  </code></pre>
  
  <p>Personally, I often turn a mutable array into an NSArray when I return from methods like this just because I feel like it's "safer" or more "correct" somehow. Although to be honest, I've never had a problem returning a mutable array that was cast to an NSArray, so it's probably a non-issue in reality - but is there a best practice for situations like this?</p>