On 2014-12-29 22:39, Christian Schneider wrote:

I just report another finding here. It's about properties and NSStrings.
So far, it was possible to set the strings of an alert like this (source
copied from the Chocolat example):

auto alert = new NSAlert ;
alert.messageText = "Want Chocolate?" ;
alert.informativeText = "Chocolate is sweet." ;

This now needs to be written like this:

auto alert = new NSAlert ;
alert.setMessageText("Want Chocolate?") ;
alert.setInformativeText("Chocolate is sweet.") ;

In the NSAlert class, the respective code is:

extern (Objective-C)
class NSAlert : NSObject {
   @property {
     NSString messageText() ;
     void setMessageText(NSString text) @selector("setMessageText:")  ;

    NSString informativeText() ;
    void setInformativeText(NSString text)
@selector("setInformativeText:")  ;

Of course, the property read/write access style is again just a
convenience, but for somebody coming from Objective-C, it is "natural"
to do it either way.

It might be some issue with properties. I'll have to look into that as well. D/Objective-C has some special treatment for properties. As a workaround you do one of the following alternatives:

* Declare the method as "messageText" instead of "setMessageText"
* Add a alias for "setMessageText" to "messageText"

* Add a method, "messageText", that forwards to "setMessageText". Any D method that takes one argument can be called like a setter

* Add an overload for "messageText" to take an argument as well

You might need to drop @property for some of these alternatives

/Jacob Carlborg

Reply via email to