@@ -99,6 +99,8 @@ 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
+ *//*:
102
104
👫 Command
103
105
----------
104
106
@@ -250,6 +252,8 @@ intContext.assign(c, value: 3)
250
252
251
253
var result = expression? . evaluate ( intContext)
252
254
/*:
255
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Interpreter)
256
+ *//*:
253
257
🍫 Iterator
254
258
-----------
255
259
@@ -342,6 +346,8 @@ messagesMediator.addColleague(user1)
342
346
343
347
user0. send ( " Hello " ) // user1 receives message
344
348
/*:
349
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Mediator)
350
+ *//*:
345
351
💾 Memento
346
352
----------
347
353
@@ -373,14 +379,14 @@ class GameState {
373
379
/*:
374
380
Caretaker
375
381
*/
376
- class CheckPoint {
377
- class func saveState( memento: Memento , keyName: String = DPMementoGameState) {
382
+ enum CheckPoint {
383
+ static func saveState( memento: Memento , keyName: String = DPMementoGameState) {
378
384
let defaults = NSUserDefaults . standardUserDefaults ( )
379
385
defaults. setObject ( memento, forKey: keyName)
380
386
defaults. synchronize ( )
381
387
}
382
388
383
- class func restorePreviousState( keyName keyName: String = DPMementoGameState) -> Memento {
389
+ static func restorePreviousState( keyName keyName: String = DPMementoGameState) -> Memento {
384
390
let defaults = NSUserDefaults . standardUserDefaults ( )
385
391
386
392
return defaults. objectForKey ( keyName) as? Memento ?? Memento ( )
@@ -459,6 +465,8 @@ var testChambers = TestChambers()
459
465
testChambers. observer = observerInstance
460
466
testChambers. testChamberNumber++
461
467
/*:
468
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Observer)
469
+ *//*:
462
470
🐉 State
463
471
---------
464
472
@@ -518,6 +526,8 @@ context.changeStateToAuthorized(userId: "admin")
518
526
context. changeStateToUnauthorized ( )
519
527
( context. isAuthorized, context. userId)
520
528
/*:
529
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-State)
530
+ *//*:
521
531
💡 Strategy
522
532
-----------
523
533
@@ -561,8 +571,9 @@ lower.printString("O tempora, o mores!")
561
571
562
572
var upper = Printer ( strategy: UpperCaseStrategy ( ) )
563
573
upper. printString ( " O tempora, o mores! " )
564
-
565
574
/*:
575
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Strategy)
576
+ *//*:
566
577
🏃 Visitor
567
578
----------
568
579
@@ -609,3 +620,6 @@ let names = planets.map { (planet: Planet) -> String in
609
620
}
610
621
611
622
names
623
+ /*:
624
+ >**Further Examples:** [Design Patterns in Swift](https://github.com/kingreza/Swift-Visitor)
625
+ */
0 commit comments