• 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
Cocoa bindings one- or bi-directional
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa bindings one- or bi-directional


  • Subject: Cocoa bindings one- or bi-directional
  • From: Zdzislaw Losvik <email@hidden>
  • Date: Thu, 26 May 2005 16:34:29 +0200

I am stuck with that for a longer while.

I thought that binding two objects together causes each of them to be updated when the other gets updated.
Here is a simple example with to model objects bound to each other:


BinderBrick *brick1 = [[BinderBrick alloc] init];
BinderBrick *brick2 = [[BinderBrick alloc] init];
[brick1 bind:@"intValue" toObject:brick2 withKeyPath:@"intValue" options:nil];


    [brick1 setIntValue:5];
    NSLog(@"%d, %d", brick1->_intValue, brick2->_intValue);

    [brick2 setIntValue:7];
    NSLog(@"%d, %d", brick1->_intValue, brick2->_intValue);

The output is:
2005-05-26 16:08:12.436 Binder[1357] 5, 0
2005-05-26 16:08:12.437 Binder[1357] 7, 7

Judging from the output only receiver of bind... method is listening for changes. Should I use another binding:
[brick2 bind:@"intValue" toObject:brick1 withKeyPath:@"intValue" options:nil];
to accomplish bi-directional binding?


I am really confused here. Any help would be really appreciated.

Regards,
Zdzislaw Losvik
_______________________________________________
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


  • Follow-Ups:
    • Re: Cocoa bindings one- or bi-directional
      • From: Kay Roepke <email@hidden>
  • Prev by Date: Re: Function calling
  • Next by Date: saving text files with bad characters
  • Previous by thread: How should I do with tableview ?
  • Next by thread: Re: Cocoa bindings one- or bi-directional
  • Index(es):
    • Date
    • Thread