Add note about singletons to OBJC_INTEROP.md
This commit is contained in:
committed by
GitHub
parent
5219565c4d
commit
1afc5e5e90
+8
-1
@@ -32,7 +32,7 @@ The table below shows how Kotlin concepts are mapped to Swift/Objective-C and vi
|
|||||||
| Extension | Extension | Category member | [note](#category-members) |
|
| Extension | Extension | Category member | [note](#category-members) |
|
||||||
| `companion` member <- | Class method or property | Class method or property | |
|
| `companion` member <- | Class method or property | Class method or property | |
|
||||||
| `null` | `nil` | `nil` | |
|
| `null` | `nil` | `nil` | |
|
||||||
| `Singleton` | `Singleton()` | `[Singleton singleton]` | |
|
| `Singleton` | `Singleton()` | `[Singleton singleton]` | [note](#kotlin-singletons) |
|
||||||
| Primitive type | Primitive type / `NSNumber` | | [note](#nsnumber) |
|
| Primitive type | Primitive type / `NSNumber` | | [note](#nsnumber) |
|
||||||
| `Unit` return type | `Void` | `void` | |
|
| `Unit` return type | `Void` | `void` | |
|
||||||
| `String` | `String` | `NSString` | |
|
| `String` | `String` | `NSString` | |
|
||||||
@@ -116,6 +116,13 @@ Members of Objective-C categories and Swift extensions are imported to Kotlin
|
|||||||
as extensions. That's why these declarations can't be overridden in Kotlin.
|
as extensions. That's why these declarations can't be overridden in Kotlin.
|
||||||
And extension initializers aren't available as Kotlin constructors.
|
And extension initializers aren't available as Kotlin constructors.
|
||||||
|
|
||||||
|
### Kotlin singletons
|
||||||
|
|
||||||
|
Kotlin singleton (made with `object` declaration, including `companion object`)
|
||||||
|
is imported to Swift/Objective-C as class with a single instance.
|
||||||
|
The instance is available through the factory method, i.e. as
|
||||||
|
`[MySingleton mySingleton]` in Objective-C and `MySingleton()` in Swift.
|
||||||
|
|
||||||
### NSNumber
|
### NSNumber
|
||||||
|
|
||||||
While Kotlin primitive types in some cases are mapped to `NSNumber`
|
While Kotlin primitive types in some cases are mapped to `NSNumber`
|
||||||
|
|||||||
Reference in New Issue
Block a user