• 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: Binding/KVC : implicit and explicit invocation of description method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding/KVC : implicit and explicit invocation of description method


  • Subject: Re: Binding/KVC : implicit and explicit invocation of description method
  • From: Scott Anguish <email@hidden>
  • Date: Sat, 2 Oct 2004 00:01:41 -0400


On Oct 1, 2004, at 6:30 PM, Max Barel wrote:

Experimenting with bindings, I'm confused by the description stuff.

From IB, I bound an NSTextView  value (in single font mode) to an NSDictionary.description, through an NSArrayController.selection.

Running the app, the NSTextview displays the null placeholder, and crash when I change the array selection.
If I bind it to the NSDictionary, everything is like I intended. The dictionary content is correctly displayed and refreshed with the selection of the array controller.

This raise two questions:

- Is the implicit call to description to get the string form of the dictionary a normal feature? If yes I can't find this in the doc.


description
- (NSString *)description

Returns a string that representsthe contents of the receiver, formatted as a property list.If each key in the receiver is an NSString the entries are listedin ascending order, by key. Otherwise, the order in which the entriesare listed is undefined.

So, yes, it's documented.  I'm not sure that's how I'd get a plist to do anything with though.  I'd suggest instead using + dataFromPropertyList:format:errorDescription:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSPropertyListSerialztion.html#//apple_ref/doc/ uid/20000942/BAJGGEJG


- Why an explicit call to description method is then wrong? I suppose it end up as NSDictionary.description.description, but why?


    It's a bug.  If the object is being observed via automatic observing, a proxy is used in place of the original object.  In this case description's behavior was altered so that it returns different information when the object is being observed.  

    If it's in a framework, perhaps try descriptionWithLocale: if it's supported... I'm not sure I've found a situation where this couldn't be worked around

    
    

I read in an other thread a reply from Scott Anguish stating :

    description has problems with KVO/bindings..
    rename your method and change the bindings to that new name.

But what if the object is from a framework?
What exactly is the description problem?



On Oct 1, 2004, at 6:30 PM, Max Barel wrote:

Experimenting with bindings, I'm confused by the description stuff.

From IB, I bound an NSTextView  value (in single font mode) to an NSDictionary.description, through an NSArrayController.selection.

Running the app, the NSTextview displays the null placeholder, and crash when I change the array selection.
If I bind it to the NSDictionary, everything is like I intended. The dictionary content is correctly displayed and refreshed with the selection of the array controller.

This raise two questions:

- Is the implicit call to description to get the string form of the dictionary a normal feature? If yes I can't find this in the doc.


description
- (NSString *)description

Returns a string that representsthe contents of the receiver, formatted as a property list.If each key in the receiver is an NSString the entries are listedin ascending order, by key. Otherwise, the order in which the entriesare listed is undefined.

So, yes, it's documented.  I'm not sure that's how I'd get a plist to do anything with though.  I'd suggest instead using + dataFromPropertyList:format:errorDescription:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSPropertyListSerialztion.html#//apple_ref/doc/ uid/20000942/BAJGGEJG


- Why an explicit call to description method is then wrong? I suppose it end up as NSDictionary.description.description, but why?


    It's a bug.  If the object is being observed via automatic observing, a proxy is used in place of the original object.  In this case description's behavior was altered so that it returns different information when the object is being observed.  

    If it's in a framework, perhaps try descriptionWithLocale: if it's supported... I'm not sure I've found a situation where this couldn't be worked around

    
    

I read in an other thread a reply from Scott Anguish stating :

    description has problems with KVO/bindings..
    rename your method and change the bindings to that new name.

But what if the object is from a framework?
What exactly is the description problem?




_______________________________________________
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: 
 >Binding/KVC : implicit and explicit invocation of description method (From: Max Barel <email@hidden>)

  • Prev by Date: Scripting and objectSpecifier issue
  • Next by Date: Re: Scripting and objectSpecifier issue
  • Previous by thread: Binding/KVC : implicit and explicit invocation of description method
  • Next by thread: Re: Binding/KVC : valid accessor for framework objects. (was: implicit and explicit invocation of description method)
  • Index(es):
    • Date
    • Thread