Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ This approach supports lazy initialization because Swift lazily initializes clas

Class constants were introduced in Swift 1.2. If you need to support an earlier version of Swift, use the nested struct approach below or a global constant.

If you are using Swift 3.0.1 or above, the `init` method definition must be preceeded by the [`override` keyword][override]:

```swift
override init() {
println("AAA");
}
```

### Approach B: Nested struct

```swift
Expand Down Expand Up @@ -63,3 +71,5 @@ class SingletonC {
```

I'm fairly certain there's no advantage over the nested struct approach but I'm including it anyway as I find the differences in syntax interesting.

[override]: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Inheritance.html#//apple_ref/doc/uid/TP40014097-CH17-ID196