Skip to content

Commit 28cd0f1

Browse files
committed
Merge pull request ochococo#40 from ochococo/bugfix/singleton_private_init
Private initialization to ensure just one instance is created.
2 parents a3b0037 + 1be549a commit 28cd0f1

File tree

7 files changed

+19
-1228
lines changed

7 files changed

+19
-1228
lines changed

Design-Patterns.playground.zip

13 KB
Binary file not shown.

Design-Patterns.playground/contents.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,10 @@ There are very few applications, do not overuse this pattern!
765765
*/
766766
class DeathStarSuperlaser {
767767
static let sharedInstance = DeathStarSuperlaser()
768+
769+
private init() {
770+
// Private initialization to ensure just one instance is created.
771+
}
768772
}
769773
/*:
770774
### Usage:

Design-Patterns.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,10 @@ There are very few applications, do not overuse this pattern!
830830
```swift
831831
class DeathStarSuperlaser {
832832
static let sharedInstance = DeathStarSuperlaser()
833+
834+
private init() {
835+
// Private initialization to ensure just one instance is created.
836+
}
833837
}
834838
```
835839

0 commit comments

Comments
 (0)