title: Swift, Access parent properties in child class
body: <p>My problem is I don´t jnow how to access parent properties within the child class</p>
  
  <pre><code>class imageOverlayRenderer: MKOverlayRenderer {
  var bar = self.overlay
  }
  </code></pre>
  
  <p>MKOverlayRenderer should have the property overlay</p>
  
  <p>What I really want is to write a custom subclass of MKOverlayRender to render an image, the code in Objective C is:</p>
  
  <pre><code>#import &lt;MapKit/MapKit.h&gt;
  
  @interface PVParkMapOverlayView : MKOverlayRenderer
  
  - (instancetype)initWithOverlay:(id&lt;MKOverlay&gt;)overlay overlayImage:(UIImage *)overlayImage;
  
  @end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#import "PVParkMapOverlayView.h"
  
  @interface PVParkMapOverlayView ()
  
  @property (nonatomic, strong) UIImage *overlayImage;
  
  @end
  
  @implementation PVParkMapOverlayView
  
  - (instancetype)initWithOverlay:(id&lt;MKOverlay&gt;)overlay overlayImage:(UIImage *)overlayImage {
      self = [super initWithOverlay:overlay];
      if (self) {
          _overlayImage = overlayImage;
      }
  
      return self;
  }
  
  - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
      CGImageRef imageReference = self.overlayImage.CGImage;
  
      MKMapRect theMapRect = self.overlay.boundingMapRect;
      CGRect theRect = [self rectForMapRect:theMapRect];
  
      CGContextScaleCTM(context, 1.0, -1.0);
      CGContextTranslateCTM(context, 0.0, -theRect.size.height);
      CGContextDrawImage(context, theRect, imageReference);
  }
  
  @end
  </code></pre>