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

typedef, bindings, and Objective-C


  • Subject: typedef, bindings, and Objective-C
  • From: patrick machielse <email@hidden>
  • Date: Wed, 6 Aug 2008 12:47:41 +0200

While maintaining some older Obj-C++ code I ran into the following issue: typedef'ed pointer/object types break bindings in Objective-C. To illustrate, the model code is similar to this:

Model.mm
========
#import <Cocoa/Cocoa.h>

typedef NSString MyString;

@interface Model : NSObject {
    MyString *text;
}
@end

@implementation Model
- (MyString *)text { return @"testing"; }
@end
++++++++

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.

Notes:

-) I'm running Mac OS X 10.5.4
-) typedefed ints, floats, etc. work, obviously.
-) -[Model respondsToSelector:@selector(text)] always returns YES, even when -[Model valueForKey:@"text"] fails.


Should I have expected this?

patrick
--
Patrick Machielse
Hieper Software

http://www.hieper.nl
email@hidden
_______________________________________________

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


  • Follow-Ups:
    • Re: typedef, bindings, and Objective-C
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Distributed Objects, NSFileHandle and file transfer
  • Next by Date: Re: KBML Generator/Parser
  • Previous by thread: Re: Distributed Objects, NSFileHandle and file transfer
  • Next by thread: Re: typedef, bindings, and Objective-C
  • Index(es):
    • Date
    • Thread