@@ -99,6 +99,9 @@ atm.canWithdraw(100) // Can withdraw - 1x100
99
99
atm. canWithdraw ( 165 ) // Cannot withdraw because ATM doesn't has bill with value of 5
100
100
atm. canWithdraw ( 30 ) // Can withdraw - 1x20, 2x10
101
101
/*:
102
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Chain-Of-Responsibility)
103
+ */
104
+ /*:
102
105
👫 Command
103
106
----------
104
107
@@ -250,6 +253,9 @@ intContext.assign(c, value: 3)
250
253
251
254
var result = expression? . evaluate ( intContext)
252
255
/*:
256
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Interpreter)
257
+ */
258
+ /*:
253
259
🍫 Iterator
254
260
-----------
255
261
@@ -342,6 +348,9 @@ messagesMediator.addColleague(user1)
342
348
343
349
user0. send ( " Hello " ) // user1 receives message
344
350
/*:
351
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Mediator)
352
+ */
353
+ /*:
345
354
💾 Memento
346
355
----------
347
356
@@ -373,14 +382,14 @@ class GameState {
373
382
/*:
374
383
Caretaker
375
384
*/
376
- class CheckPoint {
377
- class func saveState( memento: Memento , keyName: String = DPMementoGameState) {
385
+ enum CheckPoint {
386
+ static func saveState( memento: Memento , keyName: String = DPMementoGameState) {
378
387
let defaults = NSUserDefaults . standardUserDefaults ( )
379
388
defaults. setObject ( memento, forKey: keyName)
380
389
defaults. synchronize ( )
381
390
}
382
391
383
- class func restorePreviousState( keyName keyName: String = DPMementoGameState) -> Memento {
392
+ static func restorePreviousState( keyName keyName: String = DPMementoGameState) -> Memento {
384
393
let defaults = NSUserDefaults . standardUserDefaults ( )
385
394
386
395
return defaults. objectForKey ( keyName) as? Memento ?? Memento ( )
@@ -459,6 +468,9 @@ var testChambers = TestChambers()
459
468
testChambers. observer = observerInstance
460
469
testChambers. testChamberNumber++
461
470
/*:
471
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Observer)
472
+ */
473
+ /*:
462
474
🐉 State
463
475
---------
464
476
@@ -518,6 +530,9 @@ context.changeStateToAuthorized(userId: "admin")
518
530
context. changeStateToUnauthorized ( )
519
531
( context. isAuthorized, context. userId)
520
532
/*:
533
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-State)
534
+ */
535
+ /*:
521
536
💡 Strategy
522
537
-----------
523
538
@@ -561,7 +576,9 @@ lower.printString("O tempora, o mores!")
561
576
562
577
var upper = Printer ( strategy: UpperCaseStrategy ( ) )
563
578
upper. printString ( " O tempora, o mores! " )
564
-
579
+ /*:
580
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Strategy)
581
+ */
565
582
/*:
566
583
🏃 Visitor
567
584
----------
@@ -609,3 +626,6 @@ let names = planets.map { (planet: Planet) -> String in
609
626
}
610
627
611
628
names
629
+ /*:
630
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Visitor)
631
+ */
0 commit comments