Find it on GitHub.

A simple class that generates CoreImage CIFilter subclasses to allow the use of property setters to set values on filters, compile-time type-checking and autocomplete.

The CoreImage framework can be a daunting experience, especially for the novice. With heavy reliance on KVC, misspelled property names are a regular occurrence and there is zero code completion. The following snippet demonstrates the problem very well.

Almost always, you’ll have to make a trip to the documentation to retrieve the correct name of the filter, look up properties that must be set and reference the default values that are set automatically. Being extremely lazy in that sense, I’ve create a generator to automatically create CIFilter subclasses of all available filters on the platform, create the header and implementation files, and include all the default values and types for each filter property. Like so:

On iOS, the header file contains 130 subclasses of all available CIFilter types. Each subclasses has a property corresponding to adjustable values that exist for each filter. Creating a filter no longer requires remembering it’s name and exact spelling, Xcode will assist with auto-completion. Also, no need to reference the documentation for default values and available properties. Simply start typing “input” and auto-complete will work its magic.

You can now use the subclass:

The generator supports both iOS and Mac OS so generating CIFilter subclasses is easy regardless of the platform:

You can provide your own file name and prefix for full customizability.

On iOS setting convertScalars will automatically add setters for NSValue types. These NSValue types only exist for the purpose of wrapping CGAffineTransform structs and offer an overwhelmingly ugly API:

You will now be able to set a transform like so:

You can use DBGeneratorCI to generate your own custom subclasses, or you can use the pre-generated subclasses found in the “iOS Generated” and “Mac OS Generated” folders in this repository. Hopefully, this will make using Core Image a much more enjoyable process for you. I know it has for me.