@@ -13,6 +13,14 @@ A short cheat-sheet with Xcode 8.2 Playground ([Design-Patterns.playground.zip](
13
13
* [ Creational] ( #creational )
14
14
* [ Structural] ( #structural )
15
15
16
+
17
+ ``` swift
18
+
19
+ Behavioral |
20
+ [Creational](Creational) |
21
+ [Structural](Structural)
22
+ ```
23
+
16
24
Behavioral
17
25
==========
18
26
@@ -126,6 +134,9 @@ atm.canWithdraw(amount: 30) // Can withdraw - 1x20, 2x10
126
134
127
135
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Chain-Of-Responsibility )
128
136
137
+ ``` swift
138
+
139
+ ```
129
140
130
141
👫 Command
131
142
----------
@@ -291,6 +302,10 @@ var result = expression.evaluate(context)
291
302
292
303
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Interpreter )
293
304
305
+ ``` swift
306
+
307
+ ```
308
+
294
309
🍫 Iterator
295
310
-----------
296
311
@@ -403,6 +418,9 @@ spamMonster(message: "I'd Like to Add you to My Professional Network", worker: m
403
418
404
419
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Mediator )
405
420
421
+ ``` swift
422
+
423
+ ```
406
424
407
425
💾 Memento
408
426
----------
@@ -557,6 +575,9 @@ testChambers.testChamberNumber += 1
557
575
558
576
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Observer )
559
577
578
+ ``` swift
579
+
580
+ ```
560
581
561
582
🐉 State
562
583
---------
@@ -625,6 +646,9 @@ userContext.changeStateToUnauthorized()
625
646
626
647
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-State )
627
648
649
+ ``` swift
650
+
651
+ ```
628
652
629
653
💡 Strategy
630
654
-----------
@@ -678,6 +702,10 @@ upper.print("O tempora, o mores!")
678
702
679
703
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Strategy )
680
704
705
+ ``` swift
706
+
707
+ ```
708
+
681
709
🏃 Visitor
682
710
----------
683
711
@@ -771,6 +799,10 @@ The abstract factory pattern is used to provide a client with a set of related o
771
799
The "family" of objects created by the factory are determined at run-time.
772
800
773
801
### Example
802
+
803
+ ``` swift
804
+
805
+ ```
774
806
775
807
Protocols
776
808
@@ -903,6 +935,10 @@ let deathStar = DeathStar(builder:empire)
903
935
904
936
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Builder )
905
937
938
+ ``` swift
939
+
940
+ ```
941
+
906
942
🏭 Factory Method
907
943
-----------------
908
944
@@ -1011,6 +1047,10 @@ Eduardo.name = "Eduardo"
1011
1047
1012
1048
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Prototype )
1013
1049
1050
+ ``` swift
1051
+
1052
+ ```
1053
+
1014
1054
💍 Singleton
1015
1055
------------
1016
1056
@@ -1118,6 +1158,10 @@ oldFormat.angleV
1118
1158
1119
1159
> ** Further Examples:** [ Design Patterns in Swift] ( https://github.com/kingreza/Swift-Adapter )
1120
1160
1161
+ ``` swift
1162
+
1163
+ ```
1164
+
1121
1165
🌉 Bridge
1122
1166
----------
1123
1167
@@ -1488,7 +1532,7 @@ protocol HEVSuitMedicalAid {
1488
1532
1489
1533
class HEVSuit : HEVSuitMedicalAid {
1490
1534
func administerMorphine () -> String {
1491
- return " Morphine aministered ."
1535
+ return " Morphine administered ."
1492
1536
}
1493
1537
}
1494
1538
@@ -1514,3 +1558,6 @@ Info
1514
1558
====
1515
1559
1516
1560
📖 Descriptions from: [ Gang of Four Design Patterns Reference Sheet] ( http://www.blackwasp.co.uk/GangOfFour.aspx )
1561
+
1562
+
1563
+ ``` swift
0 commit comments