FROM : Shamyl Zakariya
DATE : Wed Apr 04 19:26:42 2007
It worked!
Thank you Mike, I really appreciate this. I've been writing Cocoa
code since late 2002, but most of my work is graphics/physics written
in C++ so my usage of Cocoa has been entirely of the old-school pre-
bindings nature ( Objective-C++ GUI atop a C++ core ).
Bindings seem completely orthogonal to how I've done GUI programming
traditionally; I have a lot of re-education to go through. In fact,
my greatest problem is that I don't even know how to *ask* a bindings
question. There's a lot of new terminology I'm going to have to grok
to be able to effectively ask questions here.
Thanks again,
<email_removed>
In the same episode, the scientist suggests that the
debigulation can only be reversed by a rebigulator.
-- wikipedia
On Apr 4, 2007, at 10:21 AM, Mike Abdullah wrote:
> Hi Shamyl, having seen your screenshots, I see what the issue is.
>
> You are correctly observing the array itself so that KVO
> notifications get sent that an object has been added or removed
> from the array. However, notice this method:
>
> [self setKeys:
> [NSArray arrayWithObjects:
> @"values",
> @"values.value",
> nil]
> triggerChangeNotificationsForDependentKey: @"output"];
>
> It's "keys" not "keyPaths" , so you can't have the @"values.value"
> work correctly.
>
> What I suggest you do instead, is bind your text field to
> values.value. Calling [-valueForKeyPath: @"values.value"] wo;;
> return an NSArray of NSStrings.
>
> You want to add these strings together, so write an
> NSValueTransformer whose -transformedValue: method looks something
> like this:
>
> - (id)transformedValue:(id)value
> {
> return [value componentsJoinedByString:@", "];
> }
>
> And use that as the value transformer for your new binding. If you
> post a sample project, I'll happily mod it so you can see.
>
> Mike.
DATE : Wed Apr 04 19:26:42 2007
It worked!
Thank you Mike, I really appreciate this. I've been writing Cocoa
code since late 2002, but most of my work is graphics/physics written
in C++ so my usage of Cocoa has been entirely of the old-school pre-
bindings nature ( Objective-C++ GUI atop a C++ core ).
Bindings seem completely orthogonal to how I've done GUI programming
traditionally; I have a lot of re-education to go through. In fact,
my greatest problem is that I don't even know how to *ask* a bindings
question. There's a lot of new terminology I'm going to have to grok
to be able to effectively ask questions here.
Thanks again,
<email_removed>
In the same episode, the scientist suggests that the
debigulation can only be reversed by a rebigulator.
-- wikipedia
On Apr 4, 2007, at 10:21 AM, Mike Abdullah wrote:
> Hi Shamyl, having seen your screenshots, I see what the issue is.
>
> You are correctly observing the array itself so that KVO
> notifications get sent that an object has been added or removed
> from the array. However, notice this method:
>
> [self setKeys:
> [NSArray arrayWithObjects:
> @"values",
> @"values.value",
> nil]
> triggerChangeNotificationsForDependentKey: @"output"];
>
> It's "keys" not "keyPaths" , so you can't have the @"values.value"
> work correctly.
>
> What I suggest you do instead, is bind your text field to
> values.value. Calling [-valueForKeyPath: @"values.value"] wo;;
> return an NSArray of NSStrings.
>
> You want to add these strings together, so write an
> NSValueTransformer whose -transformedValue: method looks something
> like this:
>
> - (id)transformedValue:(id)value
> {
> return [value componentsJoinedByString:@", "];
> }
>
> And use that as the value transformer for your new binding. If you
> post a sample project, I'll happily mod it so you can see.
>
> Mike.
| Related mails | Author | Date |
|---|---|---|
| Shamyl Zakariya | Apr 3, 23:47 | |
| Shamyl Zakariya | Apr 4, 14:23 | |
| Mike Abdullah | Apr 4, 16:21 | |
| Shamyl Zakariya | Apr 4, 19:26 |






Cocoa mail archive

