[Openmcl-devel] Determining OSX version at runtime

Raffael Cavallaro raffaelcavallaro at mac.com
Fri Aug 27 14:12:29 UTC 2010


On Aug 27, 2010, at 1:08 AM, Neil Baylis wrote:

> There's a feature that's available in 10.6 that's not available in 10.5, specifically, the ability to assign an NSImage directly to the content property of a CALayer in Apple's Core Animation technology.

It might be easiest and most fool-proof to test for specific selectors in the relevant framework that are known to be present only after a certain version of the framework. Here, that means selectors that are 10.6 and later only.

Since you probably don't want to instantiate a CALayer just to test for framework version, look for a CALayer class method that is 10.6 and later only:

needsDisplayForKey:

is such a selector so:

;; make sure that CALayer is present, so test that QuartzCore framework is loaded

(defun framework-loaded-p (framework-namestring) ;; case sensitive
  (let* ((frameworks (#/allFrameworks ns:ns-bundle)))
    (loop for i below (#/count frameworks)
      for current-framework = (ccl::lisp-string-from-nsstring
                               (#/bundleIdentifier (#/objectAtIndex: frameworks i)))
      when (search framework-namestring current-framework)
      return current-framework)))

;; see if the CALayer class responds to this 10.6 and later only selector

(defun ca-layer-snow-leopard-p ()
  (if (not (framework-loaded-p "QuartzCore"))
    (warn "cannot run this test unless the QuarzCore framework is loaded")
    (#/respondsToSelector: ns:ca-layer (ccl::@selector "needsDisplayForKey:"))))

warmest regards,

Ralph




Raffael Cavallaro
raffaelcavallaro at me.com








More information about the Openmcl-devel mailing list