Programmatic binding to Quartz Composition working in one direction
Programmatic binding to Quartz Composition working in one direction
- Subject: Programmatic binding to Quartz Composition working in one direction
- From: Chris Adamson <email@hidden>
- Date: Sun, 20 Jan 2008 18:05:04 -0500
I'm sorry if this is a stupid post. I'm experimenting with Cocoa
bindings and not fully understanding it.
I have a Quartz Composer composition with an published input called
"movieLevelString" (yes, ultimately to show the audio level of a
playing movie). I want to bind this to the return value of a method
in my controller. I think I have to make this binding
programmatically, since I can't really "see" either the QC input or my
controller's method in IB.
After trying various combinations of Object Controllers and binding
statements that coughed up "this class is not key value coding-
compliant for the key" errors at runtime, I found an arrangement that
kind of works. My controller has the methods movieLevel and
setMovieLevel, which trivially manage a _movieLevel NSString. Then I
call the following in awakeFromNib:
[self bind:@"movieLevelString"
toObject:patchController
withKeyPath:@"patch.movieLevelString.value"
options:nil];
Now here's the part I don't get. At the top of awakeFromNib, before
bind:, I set the value "undef'ed". At the bottom, after binding, I
try to set it again, this time to "whatever". I never see the string
"whatever" get displayed in the QCView, but some NSLog statements show
that the composition's default value for the input, "Hello World!",
gets sent back to my controller:
2008-01-20 17:21:08.839 QCLevelMeterExperiment1[1608:10b] awakeFromNib!
2008-01-20 17:21:08.853 QCLevelMeterExperiment1[1608:10b]
_movieLevelString now == undef'ed
2008-01-20 17:21:08.882 QCLevelMeterExperiment1[1608:10b]
movieLevelString!
2008-01-20 17:21:08.911 QCLevelMeterExperiment1[1608:10b]
movieLevelString!
2008-01-20 17:21:08.912 QCLevelMeterExperiment1[1608:10b]
_movieLevelString now == Hello World!
2008-01-20 17:21:08.914 QCLevelMeterExperiment1[1608:10b] Called bind
2008-01-20 17:21:08.915 QCLevelMeterExperiment1[1608:10b]
_movieLevelString now == whatever
So what I don't get is why this binding only seems to work in one
direction, from the QC patch back to my controller, but not from my
controller back to QC. Looking at Aaron Hillegass' book, I wondered
if I needed to override observeValueForKeyPath, but from what I can
tell, it isn't being called.
I assume the problem is me being stupid and getting ahead of myself
without having a deep and profound understanding of Cocoa bindings.
So what does it take for my sets to get reflected in QC?
--Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden