December 29, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | > It's the destructor in NSObject that causes the problem. I'll take a look. Remove that and your example will work, after you import the missing "foundation.runtime" in "app". Once again, thank you very much for your help! It works now with the new @selector style, and I would had the biggest problems finding out that it was the destructor making dmd bail out a -11. --- 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. |
December 31, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christian Schneider | 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 |
Copyright © 1999-2021 by the D Language Foundation