Theocacao
Leopard
Design Element
Comment on "Convert an NSImage to CIImage"
by Peter Hosey — Dec 03
“The one minor catch here is that Cocoa automatically includes CIImage.h but not CIFilter.h, so you need to explictly include it at the top of the file:”

Cocoa doesn't implicitly import anything from QuartzCore. It does currently, but it's not guaranteed to; it only imports CIImage so that it can add a category on that class. Relying on that implicit include is unclean at best, and at worst, it will cause compiler errors.

The correct way is to import QuartzCore.h:

#import <QuartzCore/QuartzCore.h>

That's the general rule on importing anything from a framework: Import the framework's overall header, which is named after the framework itself. Importing only specific headers invites preprocessor and compiler errors (error: FOO not defined). It may not happen the first 100 times you do it, but it will happen at some point. And this is Apple-defined behavior (http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html).

The only Apple public framework for which this doesn't work is Message.framework. There is no <Message/Message.h>; you must import <Message/NSMailDelivery.h> directly. No idea why.

And before anybody complains about the performance cost of importing the whole framework: Set a prefix header and tell Xcode to precompile it, and then don't worry about it.
Back to "Convert an NSImage to CIImage"
Design Element

Copyright © Scott Stevenson 2004-2015