I'm working through an experiment, and I think I'm close, but I'm not quite lining things up. I've Googled old list entries and haven't found an answer yet.

In a nutshell, I want to bind the return value of a method in my main window's controller to an input on Quartz Composer composition. Ultimately, the demo will use QC to render the audio level of a QuickTime movie, which will satisfy my curiosity about using QC as a nifty way to render application data.

The trick is getting the bindings worked out. I've been working from the Quartz Composer Programming Guide and the Cocoa Bindings Programming Topics docs, as well as various tech notes and blogs I've found by way of Google.

The first thing I wanted to convince myself of is that it would work to bind a method's return value to a GUI component (this is implicit in KVC looking for methods or variables that match the bound key; I just wanted to see it for myself). I created an Object Controller, connected it to MyController in IB, and used IB to bind an NSTextField to Object Controller.selection.movieLevel. Works fine, returns my current dummy value.

So next, I started working on the QC side of the equation. I added a QCView and a QCPatchController, loaded the the composition into the controller, and connected the view to the controller with IB. Simulating this from IB worked: I saw my composition in the window.

Now, here's what I think is the hard part: binding the method in MyController to the input in the QC composition. It occurs to me that IB doesn't know about my controller's method name, or about the inputs to the composition. If I understand the situation, this means I need to establish the binding programmatically.

To do that, I add variables for the NSObjectController (still connected to MyController from before), and the QCPatchController to MyController.h:

        IBOutlet id patchController;
        IBOutlet NSObjectController *objController;

Note that I used a plain id because QCPatchController doesn't have a public header. OK, so I connected MyController to these respective objects, so now I think I have what I need for MyController to programmatically bind its own movieLevel method (by way of the objController) to the input on the QC composition. So I try the following in awakeFromNib:

- (void)awakeFromNib {
    NSLog(@"awakeFromNib!");
    [objController bind:@"selection.movieLevel"
        toObject:patchController
        withKeyPath:@"patch.MyText.value"
        options:nil];
    NSLog (@"Called bind");
}

And... it doesn't work. The runtime tells me that something here isn't KVC compliant:

2008-01-16 14:06:19.797 QCLevelMeterExperiment1[2244:10b] awakeFromNib!
2008-01-16 14:06:19.819 QCLevelMeterExperiment1[2244:10b] An uncaught exception was raised 2008-01-16 14:06:19.821 QCLevelMeterExperiment1[2244:10b] [<NSObjectController 0x18dd60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selection.movieLevel.


So, that's the situation. I can't tell if I'm on the right track and just haven't provided appropriate paths for the binding, or if I'm really going off in the wrong direction.

Thanks in advance for any advice. If it turns out that someone's already written this up or blogged it, then apologies for not managing to find it.

--Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to