Search code examples
objective-cioscocoacore-animationcore-image

CIFilter - Can't Change Name


From Apple's Core Animation Programming Guide, listing 4:

...
// create the filter and set its default values
CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:5.0] forKey:@"inputRadius"];

// name the filter so we can use the keypath to animate the inputIntensity
// attribute of the filter
[filter setName:@"pulseFilter"];
...

On the [filter setName... line I get a "No visible @interface for 'CIFilter' declares the selector 'setName:'

I see that filter was created using a filterWithName initializer so I suspect that its name is read-only. But then why is this example in Apple's code, as well as in many other example's I've found?


Solution

  • The writeable name property is added via a category of Core Animation additions that are only present on the Mac. See the CIFilter Animatable Properties subsection:

    Core Animation adds the following animatable properties to Core Image’s CIFilter class. See CIFilter Core Animation Additions for more information. These properties are available only on OS X.

    • name
    • enabled

    CIFilter on iOS does have a -name method, but that's only for read-only access to the filter name, and there's no matching setter.

    That section of the Core Animation Programming Guide that you link to above was copied and pasted from the original Mac version of the guide, and should be altered because it doesn't entirely apply to iOS.