Quincy Morisses reply completely resolved the issue I was having with
bindings. I realized that we exchanged emails without copying this board. I
think Quincy's reply might be helpful to others, so I'm reposting his reply
on this board:

On May 28, 2013, at 16:25 , Paul Johnson <p...@askerko.net> wrote:

Thanks, Quincey, for your reply. AFAIK, my code is KVO-compliant. (I tried
to use @property and in fact found a decent and recent example that taught
me what I needed to synchronize the slider, stepper, and textField. Before
I found this example I was getting some runtime errors about
non-compliance. I started again from scratch, following the example code,
and came up with a nice short sample program. I've still got the
initialization issue though.)

I think the best way to show what I've done is to just bundle the project
in a .dmg file and send it to you as it is very short. I hope you can
suggest something without using much of your time.


When you bind the controls to a property, they get the initial value of the
property -- the value of the control you set in IB is ignored when the
binding is established.

So you'll need to arrange for the property to be initialized to the correct
value. For example, in the Bandwidth class:

- (id) init {
self = [super init];
_densityEstimationBandwidth = 10;
return self;
}


There is an alternative way to do this with literally no lines of code
(though I it's probably going to be too simple-minded an approach when your
app gets a bit more complicated). Select the Bandwidth object in your XIB,
and display the identity inspector (3rd icon from the left). Add a
user-defined run-time attribute, specifying "densityEstimationBandwidth"
for the key path, "Number" for the type, and the desired initial value.


On Tue, May 28, 2013 at 7:01 PM, Paul Johnson <p...@askerko.net> wrote:

> Wonderful! Thanks a lot! I owe you a beer.
>
> I learned a lot from your reply. Eventually I hope to fully understand the
> intricacies of Bindings. I think a good book on this topic would be a
> bestseller.
>
> I chose your 2nd method, setting the Key Path in the XIB file. (What I'm
> doing is converting a program that uses (arghh) Qt, and I want to minimize
> the amount of actual code I need to write so the advantage of using Xcode
> and Objective-C is totally obvious.)
>
> Again, thanks for your help.
>
>
> On Tue, May 28, 2013 at 6:48 PM, Quincey Morris <
> quinceymor...@rivergatesoftware.com> wrote:
>
>> On May 28, 2013, at 16:25 , Paul Johnson <p...@askerko.net> wrote:
>>
>> Thanks, Quincey, for your reply. AFAIK, my code is KVO-compliant. (I
>> tried to use @property and in fact found a decent and recent example that
>> taught me what I needed to synchronize the slider, stepper, and textField.
>> Before I found this example I was getting some runtime errors about
>> non-compliance. I started again from scratch, following the example code,
>> and came up with a nice short sample program. I've still got the
>> initialization issue though.)
>>
>> I think the best way to show what I've done is to just bundle the project
>> in a .dmg file and send it to you as it is very short. I hope you can
>> suggest something without using much of your time.
>>
>>
>> When you bind the controls to a property, they get the initial value of
>> the property -- the value of the control you set in IB is ignored when the
>> binding is established.
>>
>> So you'll need to arrange for the property to be initialized to the
>> correct value. For example, in the Bandwidth class:
>>
>> - (id) init {
>> self = [super init];
>> _densityEstimationBandwidth = 10;
>> return self;
>> }
>>
>>
>> There is an alternative way to do this with literally no lines of code
>> (though I it's probably going to be too simple-minded an approach when your
>> app gets a bit more complicated). Select the Bandwidth object in your XIB,
>> and display the identity inspector (3rd icon from the left). Add a
>> user-defined run-time attribute, specifying "densityEstimationBandwidth"
>> for the key path, "Number" for the type, and the desired initial value.
>>
>>
>
_______________________________________________

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