title: How to use NSVisualEffectView backwards-compatible with OSX < 10.10?
body: <p>The upcoming OSX 10.10 ("Yosemite") offers a new type of view, NSVisualEffectView, which supports through-the-window or within-the-window translucency. I'm mostly interested in through-the-window translucency, so I'm going to focus on that in this question, but it applies to within-the-window translucency as well.</p>
  
  <p>Using through-the-window translucency in 10.10 is trivial. You just place an <code>NSVisualEffectView</code> somewhere in your view hierarchy and set it's <code>blendingMode</code> to <code>NSVisualEffectBlendingModeBehindWindow</code>. That's all it takes. </p>
  
  <p>Under 10.10 you can define <code>NSVisualEffectView</code>s in IB, set their blending mode property, and you're off and running.</p>
  
  <p>However, if you want to be backwards-compatible with earlier OSX versions, you can't do that. If you try to include an <code>NSVisualEffectView</code> in your XIB, you'll crash as soon as you try to load the XIB.</p>
  
  <p>I want a "set it and forget it" solution that will offer translucency when run under 10.10 and simply degrade to an opaque view when run on earlier OS versions.</p>
  
  <p>What I've done so far is to make the view in question a normal NSView in the XIB, and then add code (called by awakeFromNib) that checks for <code>[NSVisualEffectView class] != nil</code>, and when it's the class is defined, I create an instance of the NSVisualEffectView, move all my current view's subviews to the new view, and install it in place. This works, but it's custom code that I have to write every time I want a translucent view.</p>
  
  <p>I'm thinking this might be possible using an NSProxy object. Here's what I'm thinking:</p>
  
  <p>Define a custom subclass of NSView (let's call it MyTranslucentView). In all the init methods (initWithFrame and initWithCoder) I would throw away the newly created object and instead create a subclass of NSProxy that has a private instance variable (myActualView). At init time it would decide to create the myActualView object as an NSVisualEffectView if OS>=10.10, and a normal NSView under OS&lt;10.10. </p>
  
  <p>The proxy would forward <strong>ALL</strong> messages to it's myActualView. </p>
  
  <p>This would be a fair amount of fussy, low-level code, but I think it should work.</p>
  
  <p>Has anybody done something like this? If so, can you point me in the right direction or give me any pointers?</p>
  
  <p>Apple is <strong>MUCH</strong> more open with the Beta agreement with Yosemite a than with previous Betas. I don't think I'm violating my Beta NDA by talking about this in general terms, but actual code using <code>NSVisualEffectView</code> would probably need to be shared under NDA...</p>