Skip to content

Commit 4fbd4a1

Browse files
authored
Bind to external classes instance properties (#3552)
* Bind to external classes instance properties * Attempt to fix whitespaces * Fixed trailing whitespace * Use wording based on apple.developer documentation
1 parent a0185b1 commit 4fbd4a1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/objc_interface.dd

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ $(HEADERNAV_TOC)
4343
`Objective-C` linkage.
4444
)
4545

46+
$(SECTION3 $(LNAME2 external-class, Binding to a @property (Accessor Methods)))
47+
48+
---
49+
import core.attribute : selector;
50+
51+
extern (Objective-C)
52+
extern class MTLRenderPipelineDescriptor : NSObject
53+
{
54+
NSString label() @selector("label");
55+
NSString label(NSString) @selector("setLabel:");
56+
}
57+
---
58+
59+
$(P
60+
Whenever needing to bind to Objective-C classes `@property`, one must be aware
61+
that it generates both a getter and setter. The method to get its value (getter)
62+
is the same name as the property's name. The method to set its value (setter)
63+
starts with the word "set" and then uses the capitalized property name.
64+
The setter for the property `label` is `setLabel:`.
65+
)
66+
4667
$(SECTION3 $(LNAME2 defining-class, Defining a Class))
4768

4869
---

0 commit comments

Comments
 (0)