• 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: Mutable/non-mutable bindings in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mutable/non-mutable bindings in NSTextView


  • Subject: Re: Mutable/non-mutable bindings in NSTextView
  • From: Greg Herlihy <email@hidden>
  • Date: Fri, 24 Feb 2006 23:05:39 -0800
  • Thread-topic: Mutable/non-mutable bindings in NSTextView

On 2/24/06 7:24 PM, "David" <email@hidden> wrote:

> This would appear to be a simple problem but for some reason can't
> get it to work.
>
> I am binding to the VALUE of an NSTextView which gives me an NSString
> in my model class.  When a user clicks on a button I wish to clear
> the contents of the NSTextView.  The value binding of NSTextView is a
> non-mutable string so how do I clear it?   Releasing and setting the
> NSString to empty string is not enough.

The program can either call setString:@"" on the NSTextView itself or
setValue:forKey: on the bound model object, specifying an empty string and
the name of the bound property. Calling setValue:forKey ensures that the
change is made in a key-value observing (KVO) compliant manner and that the
value of the NSTextView is properly updated.

>   And on a side note why is the DATA binding of NSTextView a mutable
> NSData object?  Seems like the bindings should be consistent as far
> as mutable/non-mutable, no?  How does one know if you will get a
> mutable object from a binding?

An NSData object is not a mutable object. Bound values are on the whole are
represented by immutable objects. Therefore to change the value of a bound
property usually requires replacing the current value with a different
object, since the object representing the current value cannot be modified.

Furthermore, some bindings are designated "read-only" and their values
cannot be replaced. The "Core Bindings Reference" documentation describes
all available bindings, including their read-only status.

Greg


 _______________________________________________
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: Mutable/non-mutable bindings in NSTextView
      • From: David <email@hidden>
    • Re: Mutable/non-mutable bindings in NSTextView
      • From: Scott Anguish <email@hidden>
References: 
 >Mutable/non-mutable bindings in NSTextView (From: David <email@hidden>)

  • Prev by Date: completely and utterly confused with NSImage + MySQL
  • Next by Date: Re: draw and ... draw, not drawing
  • Previous by thread: Mutable/non-mutable bindings in NSTextView
  • Next by thread: Re: Mutable/non-mutable bindings in NSTextView
  • Index(es):
    • Date
    • Thread