Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Add note about singletons to OBJC_INTEROP.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SvyatoslavScherbina authored Jun 6, 2018
1 parent 5219565 commit 1afc5e5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion OBJC_INTEROP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
| `companion` member <- | Class method or property | Class method or property | |
| `null` | `nil` | `nil` | |
| `Singleton` | `Singleton()` | `[Singleton singleton]` | |
| `Singleton` | `Singleton()` | `[Singleton singleton]` | [note](#kotlin-singletons) |
| Primitive type | Primitive type / `NSNumber` | | [note](#nsnumber) |
| `Unit` return type | `Void` | `void` | |
| `String` | `String` | `NSString` | |
Expand Down Expand Up @@ -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.
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

While Kotlin primitive types in some cases are mapped to `NSNumber`
Expand Down

0 comments on commit 1afc5e5

Please sign in to comment.