• 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: typedef, bindings, and Objective-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: typedef, bindings, and Objective-C


  • Subject: Re: typedef, bindings, and Objective-C
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 6 Aug 2008 06:08:53 -0500

On Aug 6, 2008, at 5:47 AM, patrick machielse wrote:

typedef NSString MyString;

[...]

In IB the value binding of an NSTextField is connected to the Model's 'text' property. This works as expected when the code is compiled as Objective-C++. Changing to Objective-C still compiles perfectly, but when the application starts an exception is thrown inside -[Model valueForUndefinedKey:]. This puzzled me, and it took me a while to realize that the typedef seemed to be causing this behavior.

[...]
Should I have expected this?

This is obscure enough that I wouldn't have any particular expectation one way or another, I guess.


Out of curiosity, what do @encode(MyString*) and @encode(MyString) provide in Objective-C vs. Objective-C++?

I know that Key-Value Coding investigates return and parameter types of the accessors to figure out whether it needs to wrap non-objects in NSValue or NSNumber. See: <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/DataTypes.html >. Also see the notes under "Support for Arbitrary Types in KVC and KVO" in the Leopard Foundation release notes <http://developer.apple.com/releasenotes/Cocoa/Foundation.html#KVCKVO >.

I suspect KVC uses @encode() or its equivalent to make these inquiries. The compiler may produce different encodings for your typedef depending on the language in use.

Cheers,
Ken
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >typedef, bindings, and Objective-C (From: patrick machielse <email@hidden>)

  • Prev by Date: Re: KBML Generator/Parser
  • Next by Date: Re: Message Framework and Garbage Collection
  • Previous by thread: typedef, bindings, and Objective-C
  • Next by thread: Dumb Q
  • Index(es):
    • Date
    • Thread