@@ -698,7 +698,7 @@ you replace a native Objective-C `@implementation Foo (Bar)` with a Swift
698
698
699
699
You create a class with this feature very differently from normal ObjC interop:
700
700
701
- 1 . Hand-write headers that declare the classes' Objective-C interface, just as
701
+ 1 . Hand-write headers that declare the class's Objective-C interface, just as
702
702
you would for a native Objective-C class. Since you're handwriting these
703
703
headers, you can write them just as you would for an Objective-C class:
704
704
splitting them across multiple files, grouping related declarations together,
@@ -720,28 +720,35 @@ You create a class with this feature very differently from normal ObjC interop:
720
720
* To implement a category in Swift, use
721
721
` @_objcImplementation(CategoryName) extension ClassName ` .
722
722
723
- * We should think about Objective-C generics.
724
-
725
- 4 . Every member of an ` @_objcImplementation ` extension should be either ` @objc `
726
- or ` final ` . The ` final ` members can be made ` public ` if you want to expose
727
- them to Swift clients. The ` @objc ` members are implicitly ` dynamic ` .
723
+ The members of an ` @_objcImplementation ` extension should fall into one of
724
+ three categories:
728
725
729
- * Eventually, we'd like to allow members which are not explicitly marked
730
- ` @objc ` . The compiler will check that they match something declared in the
731
- header, and if they do, it will automatically apply appropriate attributes.
732
- If not, it will reject them. Members with an explicit ` @objc ` will not be
733
- checked, so you can define helpers that are callable by selector but not in
734
- any header.
726
+ * ** Swift-only members** include any member marked ` final ` . These are not
727
+ ` @objc ` or ` dynamic ` and are only callable from Swift. Use these for
728
+ Swift-only APIs, random helper methods, etc.
729
+
730
+ * ** ObjC helper members** include any non-` final ` member marked ` fileprivate `
731
+ or ` private ` . These are implicitly ` @objc dynamic ` . Use these for action
732
+ methods, selector-based callbacks, and other situations where you need a
733
+ helper method to be accessible from an Objective-C message.
735
734
736
- * Eventually, we want the main ` @_objcImplementation ` extension to be able to
737
- declare stored properties that aren't in the interface. We also want
738
- ` final ` stored properties to be allowed to be resilent Swift types, but
739
- it's not clear how to achieve that without boxing them in ` __SwiftValue `
740
- (which we might do as a stopgap).
735
+ * ** Member implementations** include any other non-` final ` member. These are
736
+ implicitly ` @objc dynamic ` and must match a member declared in the
737
+ Objective-C header. Use these to implement the APIs declared in your
738
+ headers. Swift will emit an error if these don't match your headers.
739
+
740
+ Notes:
741
+
742
+ * We don't currently plan to support ObjC generics.
743
+
744
+ * Eventually, we want the main ` @_objcImplementation ` extension to be able to
745
+ declare stored properties that aren't in the interface. We also want
746
+ ` final ` stored properties to be allowed to be resilent Swift types, but
747
+ it's not clear how to achieve that without boxing them in ` __SwiftValue `
748
+ (which we might do as a stopgap).
741
749
742
- * We should think about ObjC ` direct ` members.
743
-
744
- * Access control design for ObjC methods TBD.
750
+ * We should think about ObjC "direct" members, but that would probably
751
+ require a way to spell this in Swift.
745
752
746
753
## ` @_objc_non_lazy_realization `
747
754
0 commit comments