title: How to set a property of UICollectionViewCell readonly eligantly
body: <p>I have a UITableViewCell <code>ProductsCell</code>, I registered it in a nib , and dequeue to use it.</p>
  
  <p>I want to set a property of it readonly. How to do it better?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>@property (nonatomic, strong, readonly) MyProductsVC * targetMyProductsVC;
  
  - (MyProductsVC *)targetMyProductsVC{
  
      if(!_targetMyProductsVC){
          UIResponder *target = self.nextResponder;
          do {
              target = target.nextResponder;
          } while (![target isKindOfClass: ZBMyProductsVC.self] &amp;&amp; target != nil);
          _targetMyProductsVC = (ZBMyProductsVC *)target;
  
      }
      return _targetMyProductsVC;
  }
  </code></pre>
  
  <p>I can't put the implementation. in <code>-init</code>,<code>-awakeFromNib</code> , because I use <code>UIResponder</code> to find the parent ViewController.</p>
  
  <p>Because in above methods, the cell seems like have not been added on the super view.</p>
  
  <p>If I do like this , </p>
  
  <pre><code>@property (nonatomic, strong, readonly) MyProductsVC * targetMyProductsVC;
  </code></pre>
  
  <p>Xcode reports:</p>
  
  <blockquote>
    <p>Use of undeclared identifier '_targetMyProductsVC'</p>
  </blockquote>
  
  <p>It is OK to set two property. one is inside like above , just set the other readonly property outside <code>getter</code> method (<code>return</code> the former property.)
  It a little dirty ,</p>
  
  <p><strong>any better way ?</strong></p>
  
  <p>The code can work:</p>
  
  <pre><code>@property (nonatomic, strong, readonly) MyProductsVC * targetMyProductsVCReadOnly; 
  @property (nonatomic, strong) MyProductsVC * targetMyProductsVC;
  
  
  - (MyProductsVC *)targetMyProductsVC{
  
      if(!_targetMyProductsVC){
          UIResponder *target = self.nextResponder;
          do {
              target = target.nextResponder;
          } while (![target isKindOfClass: ZBMyProductsVC.self] &amp;&amp; target != nil);
          _targetMyProductsVC = (ZBMyProductsVC *)target;
  
      }
      return _targetMyProductsVC; }
  
  
  - (MyProductsVC *)targetMyProductsVCReadOnly{
      return self.targetMyProductsVC; }
  </code></pre>