title: Is declare new property in class extension a bad practice in Objective-C?
body: <p>One strong advantage of class extension is that with class extension you can declare a readonly property in the header file and override this property in class extension as readwrite property. Like below :</p>
  
  <pre><code>//SomeClass.h
  
  @interface SomeClass : NSObject
  {
      NSInteger someInt;   //with modern runtime you can omit this line
  }
  @property (readonly) NSInteger someInt;
  @end
  
  //SomeClass.m
  @interface SomeClass ()
  @property (readwrite) NSInteger someInt;
  @end
  
  @implementation SomeClass
  @synthesize someInt;
  @end
  </code></pre>
  
  <p>But if you use a modern runtime ,you can also declare a totally new property in the class extension (which also generate an iVar for that property if there isn't).</p>
  
  <pre><code>//SomeClass.h
  
  @interface SomeClass : NSObject
  {
  }
  @end
  
  //SomeClass.m
  @interface SomeClass ()
  @property (readwrite) NSInteger someInt;
  @end
  
  @implementation SomeClass
  @synthesize someInt;
  @end
  </code></pre>
  
  <p>Here's my question : I think declare a totally new property in class extention is somehow has some side effects. Because class extension my not be in the header file and someone else who subclass the class may not know about that "secret property". And if he declare a property with the same name of that "secret property". And this new property's getter and setter method will override the super class's. Isn't this a problem?And why would modern runtime allow such thing happen?</p>
  
  <p>EDIT I posted another question about this topic , please check it out:
  <a href="https://stackoverflow.com/questions/5643893/the-risk-of-declare-new-propery-in-class-extension-ojbective-c-how-to-solve-i">The risk of declare new propery in class extension (Ojbective-C) , how to solve it?</a></p>