title: Protect from adding object to NSMutableArray in public interface
body: <p>I want to protect access to NSMutableArray in public interface</p>
  
  <p>I am trying to do this by defining property as NSArray in public interface and as NSMutableArray in private interface like this:</p>
  
  <pre><code>@interface Order : NSObject
  @property (readonly, strong, nonatomic) NSArray* comments;
  @end
  
  @interface Order()
  @property (readwrite, strong, nonatomic) NSMutableArray* comments;
  @end
  </code></pre>
  
  <p>But this doesn't work - so I have to define property in public interface NSMutableArray instead:</p>
  
  <pre><code>@interface Order
  @property (strong, nonatomic) NSMutableArray* comments;
  @end
  </code></pre>
  
  <p>The goal is to provide read-only access to comments for API clients and full access to methods like <code>addObject:</code> in the implementation.</p>
  
  <p>So defining goal more clearer:</p>
  
  <ol>
  <li>Client should have access to property as NSArray without ability to access mutation methods.</li>
  <li>Client should not have ability to update the comments to point to new value.</li>
  <li>The solution must be done without creating extra structures and array copying.</li>
  </ol>
  
  <p>So simply the question was if it's possible to make public definition of property more general (NSArray instead of NSMutableArray).</p>
  
  <p>Is there any other clean way to reach the goal or I have to use NSMutableArray everywhere?</p>
  
  <p><strong>RESOLUTION</strong></p>
  
  <p>After reviewing my original question and answers I realized that I would like to use more generic class NSArray in the public interface and NSMutableArray in the implementation - but it's just not possible for one property. So the answer is not possible.</p>
  
  <p>So I will just use single property with NSMutableArray without any extra desired protection.</p>
  
  <p>But I will also pick the most appropriate answer it might help if you really prefer protection over simplicity and efficiency.</p>