Re: Cocoa Bindings Ref.: multi-value arg bindings ?!?!
Re: Cocoa Bindings Ref.: multi-value arg bindings ?!?!
- Subject: Re: Cocoa Bindings Ref.: multi-value arg bindings ?!?!
- From: Matt Neuburg <email@hidden>
- Date: Fri, 30 Jun 2006 10:48:26 -0700
- Thread-topic: Cocoa Bindings Ref.: multi-value arg bindings ?!?!
On Fri, 30 Jun 2006 12:52:10 -0400, David Hoerl <email@hidden> said:
>There is an intriguing paragraph on pg 28 in the bindings reference
>document on multiple-value argument bindings. Is there some example
>code that demonstrates the use of it (hopefully done with IB)?
If it is done with IB, it would be example *code*, now would it? :)
Basically there's nothing to know; it's simple. Let's say you have a button
and you want it to target MyObject's doYourThing:withSecondArg:. That takes
two arguments. So first you set the target binding to MyObject's "self" and
set the selector name to "doYourThing:withSecondArg:". Now you add an
argument binding for what the first argument should be, and a second
argument binding appears, so now you add a binding for what that should be.
All done.
However, you will quickly discover that this is not as exciting as you were
hoping, because on the whole bindings are NOT the way you would like to
specify arguments. For example, consider the standard action/target
paradigm. It sends this message:
- (void) doAction: (id) sender
Now, how would you set that up from a button in the interface, in IB? You
can tell the button that its target is MyObject's "self", and you can enter
the selector name "doAction:". But now you face the argument binding, and
how on earth are you going to specify a value which is the button itself?
You can't, because this would require that you bind from the button to the
button in order to get *its* "self", and there is no way to do that! So,
irony of ironies, target/argument bindings can't be used to implement the
most basic, commonly used target/argument paradigm.
This is part of a much larger gripe that I have about how bindings work.
Very often a value that I want to specify is something that is easy to type
as text, such as a constant number; but there is no way to do that easily
with bindings. Just to give an obvious example, consider an NSSlider's
minValue. The minValue binding is great if you want to supply it
dynamically, but what if you want to supply it statically - that is, what if
you know that you always want this value to be, say, 2? You are forced to
supply an ivar or method in some other, bindable object that returns 2. That
seems nutty; you should be able to say "2" right there in IB's bindings
interface, instead of having to go to the moon and back just to fetch a "2".
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden