• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to set up manual bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to set up manual bindings


  • Subject: How to set up manual bindings
  • From: René Puls <email@hidden>
  • Date: Sun, 1 Feb 2004 20:09:24 +0100

Hi,

either I just triggered a strange bug in the controller layer, or my understanding of bindings is totally wrong. :-)

I have two instances of the same simple NSObject subclass: they are called 'view' and 'controller', each with a key 'foo'. At startup, I bind the objects together like this:

[view bind:@"foo" toObject:controller withKeyPath:@"foo" options:nil];

I would expect that, if I now set the 'foo' key of my controller, the view should be updated:

[controller setFoo:12345];

And indeed, that seems to work. But I would also expect that if I set the 'foo' key of my *view*, that the controller should be updated:

[view setFoo:54321];

But it turns out that this is *not* the case. I'm lost. I thought the whole purpose of a binding is to make sure that the two bound values are *always* the same!

Setting up another "reverse" binding seems to fix this:

[controller bind:@"foo" toObject:view withKeyPath:@"foo" options:nil];

But is this really the correct way? Do I always have to set up *two* bindings to keep two values synchronized?

Here is a sample Xcode project:
http://home.kcore.de/~kianga/public/BindTest.zip

I hope someone can enlighten me. :-)

Kind regards,
Rene Puls
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How to set up manual bindings
      • From: René Puls <email@hidden>
  • Prev by Date: Re: Dragging Image
  • Next by Date: textfield with percent sign
  • Previous by thread: Re: Dragging Image
  • Next by thread: Re: How to set up manual bindings
  • Index(es):
    • Date
    • Thread