typedef, bindings, and Objective-C
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