• 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
Re: more on two-way bindings and one-way bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: more on two-way bindings and one-way bindings


  • Subject: Re: more on two-way bindings and one-way bindings
  • From: Keary Suska <email@hidden>
  • Date: Fri, 07 Jul 2006 12:02:21 -0600
  • Thread-topic: more on two-way bindings and one-way bindings

on 7/6/06 2:03 PM, email@hidden purportedly said:

> No, in code, set NSObjectController's content (using setContent:) to
> @"byebye". Back in MyObject, "thing2" is still @"howdy"! So even this, a
> binding established in the standard way, in IB, between a controller and a
> model object, is only one-way!!

I may be wrong, or misunderstanding the issue, and forgive me if I am
reiterating what you already know, but my understanding is that setContent:
sets the content *object*, and not the value. I.e., it sets the *model
object* that the controller will use. Therefore, since you are changing the
model object from one NSString object to a *different* NSString object,
naturally the original object will not change. AFAIK, only the value is
synchronized, and not the model object itself.

> But wait, there's more!!! Instead of using setContent:, use addObject: to
> set the NSObjectController's content value to @"byebye". Now the binding
> suddenly works in the other direction - MyObject's "thing2" is now
> @"byebye"! So this is a major difference between addObject: and setContent:,
> even though the docs say that for NSObjectController they are synonyms.
>
> <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
> cepts/CntrlContent.html#//apple_ref/doc/uid/TP40002147-183285-BBCDFJHD>

I see what you mean for this doc reference--what is described may be a bit
misleading. If you look at the documentation for NSObjectController
specifically:

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas
ses/NSObjectController_Class/Reference/Reference.html#//apple_ref/doc/uid/20
002044

it says for -addObject:

"If the receiver's content is bound to another object or controller through
a relationship key, the relationship of the ³master² object is changed."

This explains to me why you are seeing the different behavior between
-setContent and -addObject. -addObject will change the model object "thing2"
in "MyObject" to the passed object, but -setContent doesn't.

Best regards,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


 _______________________________________________
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

References: 
 >more on two-way bindings and one-way bindings (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Newbie Q : writing into a text view programmatically
  • Next by Date: Re: Core Data: Single entity in NSDocument?
  • Previous by thread: more on two-way bindings and one-way bindings
  • Next by thread: Re: more on two-way bindings and one-way bindings
  • Index(es):
    • Date
    • Thread