Hello, 
I'm trying to refresh my knowledge on Core Animation, and reading Addison 
Wesley's Simplified Animation.

I created a new project from the scratch to mimic what is explained in Chapter 
6, which has a NSView on a main window.
On that instance of NSView, a CALayer is added and it is the layer where an 
image is displayed. Also a CIFilter is applied to that layer.
On the right of the NSView instance, there are a few slider controls to change 
parameters of CIFilters.

Here is a method/message for creating filters.

@synthesize imageLayer;

- (NSArray *)filters
{
        CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
        [blurFilter setDefaults];
        [blurFilter setValue:[NSNumber numberWithFloat:1.0] 
forKey:@"inputRadius"];
        [blurFilter setName:@"blur"];
        
//      CIFilter *hueFilter = [CIFilter filterWithName:@"CIHueAdjust"];
//      [hueFilter setDefaults];
//      [hueFilter setValue:[NSNumber numberWithFloat:0.0f] 
forKey:@"inputAngle"];
//      [hueFilter setName:@"hue"];
//      
//      CIFilter *colorFilter = [CIFilter filterWithName:@"CIColorControls"];
//      [colorFilter setDefaults];
//      [colorFilter setName:@"color"];
        
        
//      return [NSArray arrayWithObjects:blurFilter, hueFilter, colorFilter, 
nil];
        
//      return [NSArray arrayWithObjects:blurFilter, hueFilter, nil];
        
        return [NSArray arrayWithObject:blurFilter];
        
}

The filters are added to the instance of CALayer using setFilters:.
And a slider control, for example, is bound to 
imageLayer.filters.blur.inputRadius using the binding property in IB resource 
editing mode.
Once it is bound, it complaints this error.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '[<__NSArrayI 0x103400000> addObserver:forKeyPath:options:context:] is 
not supported. Key path: blur.inputRadius'


What is really funny is that AW's sample project for that are the same, and it 
doesn't complain that. I checked settings for target, project, xib version 
number, whether to use ARC or not just in case, and so on.

Somehow, it doesn't seem to recognize the added filter, "blur". The IB module 
suggests "imageLayer.filters". However it doesn't do so after that. However, in 
the AW's sample project, it's the same. So, I don't think it is the problem.
The AW's project was created when there was no ARC. So, I even changed the 
project setting to use ARC and others.
So, I don't think that the filter is released somehow in my own project.

So, can I ask what can be wrong with my project?

Thank you.

P.S. Personally I don't use Cocoa Binding much. I did use when it was 
introduced. But it turned out that it's very hard to debug if there is 
something wrong. I turned on NSBindingDebugLogLevel to 1 also. But it doesn't 
tell much about this problem.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to