Skip to content

Commit

Permalink
Merging upstream/master and regenerating playground file
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Abdelhafith committed Aug 25, 2014
2 parents 16274ea + 436a09b commit d113c9e
Show file tree
Hide file tree
Showing 60 changed files with 569 additions and 97 deletions.
Binary file modified Design-Patterns.playground.zip
Binary file not shown.
1 change: 0 additions & 1 deletion Design-Patterns.playground/Documentation/section-39.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ <h2 id="mediator">Mediator</h2>
<h2 id="memento">Memento</h2>
<h2 id="observer">Observer</h2>
<h2 id="state">State</h2>
<h2 id="strategy">Strategy</h2>

</section>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Design-Patterns.playground/Documentation/section-43.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<body>
<div class="content-wrapper">
<section class="section">
<h2 id="visitor">Visitor</h2>
<h2 id="strategy">Strategy</h2>

</section>
</div>
Expand Down
19 changes: 19 additions & 0 deletions Design-Patterns.playground/Documentation/section-47.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 48</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<h2 id="visitor">Visitor</h2>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions Design-Patterns.playground/Documentation/section-49.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 50</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p><strong>Usage:</strong></p>

</section>
</div>
</body>
</html>
148 changes: 53 additions & 95 deletions Design-Patterns.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,99 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version="3.0" sdk="macosx" allows-reset="YES">
<playground version='3.0' sdk='macosx' allows-reset='YES'>
<sections>
<code source-file-name="section-0.swift">
</code>
<documentation relative-path="section-1.html">
</documentation>
<code source-file-name="section-2.swift">
</code>
<documentation relative-path="section-3.html">
</documentation>
<code source-file-name="section-4.swift">
</code>
<documentation relative-path="section-5.html">
</documentation>
<code source-file-name="section-6.swift">
</code>
<documentation relative-path="section-7.html">
</documentation>
<code source-file-name="section-8.swift">
</code>
<documentation relative-path="section-9.html">
</documentation>
<code source-file-name="section-10.swift">
</code>
<documentation relative-path="section-11.html">
</documentation>
<code source-file-name="section-12.swift">
</code>
<documentation relative-path="section-13.html">
</documentation>
<code source-file-name="section-14.swift">
</code>
<documentation relative-path="section-15.html">
</documentation>
<code source-file-name="section-16.swift">
</code>
<documentation relative-path="section-17.html">
</documentation>
<code source-file-name="section-18.swift">
</code>
<documentation relative-path="section-19.html">
</documentation>
<code source-file-name="section-20.swift">
</code>
<documentation relative-path="section-21.html">
</documentation>
<code source-file-name="section-22.swift">
</code>
<documentation relative-path="section-23.html">
</documentation>
<code source-file-name="section-24.swift">
</code>
<documentation relative-path="section-25.html">
</documentation>
<code source-file-name="section-26.swift">
</code>
<documentation relative-path="section-27.html">
</documentation>
<code source-file-name="section-28.swift">
</code>
<documentation relative-path="section-29.html">
</documentation>
<code source-file-name="section-30.swift">
</code>
<documentation relative-path="section-31.html">
</documentation>
<code source-file-name="section-32.swift">
</code>
<documentation relative-path="section-33.html">
</documentation>
<code source-file-name="section-34.swift">
</code>
<documentation relative-path="section-35.html">
</documentation>
<code source-file-name="section-36.swift">
</code>
<documentation relative-path="section-37.html">
</documentation>
<code source-file-name="section-38.swift">
</code>
<documentation relative-path="section-39.html">
</documentation>
<code source-file-name="section-40.swift">
</code>
<documentation relative-path="section-41.html">
</documentation>
<code source-file-name="section-42.swift">
</code>
<documentation relative-path="section-43.html">
</documentation>
<code source-file-name="section-44.swift">
</code>
<documentation relative-path="section-45.html">
</documentation>
<code source-file-name="section-46.swift">
</code>
<code source-file-name='section-1.swift'/>
<documentation relative-path='section-1.html'/>
<code source-file-name='section-3.swift'/>
<documentation relative-path='section-3.html'/>
<code source-file-name='section-5.swift'/>
<documentation relative-path='section-5.html'/>
<code source-file-name='section-7.swift'/>
<documentation relative-path='section-7.html'/>
<code source-file-name='section-9.swift'/>
<documentation relative-path='section-9.html'/>
<code source-file-name='section-11.swift'/>
<documentation relative-path='section-11.html'/>
<code source-file-name='section-13.swift'/>
<documentation relative-path='section-13.html'/>
<code source-file-name='section-15.swift'/>
<documentation relative-path='section-15.html'/>
<code source-file-name='section-17.swift'/>
<documentation relative-path='section-17.html'/>
<code source-file-name='section-19.swift'/>
<documentation relative-path='section-19.html'/>
<code source-file-name='section-21.swift'/>
<documentation relative-path='section-21.html'/>
<code source-file-name='section-23.swift'/>
<documentation relative-path='section-23.html'/>
<code source-file-name='section-25.swift'/>
<documentation relative-path='section-25.html'/>
<code source-file-name='section-27.swift'/>
<documentation relative-path='section-27.html'/>
<code source-file-name='section-29.swift'/>
<documentation relative-path='section-29.html'/>
<code source-file-name='section-31.swift'/>
<documentation relative-path='section-31.html'/>
<code source-file-name='section-33.swift'/>
<documentation relative-path='section-33.html'/>
<code source-file-name='section-35.swift'/>
<documentation relative-path='section-35.html'/>
<code source-file-name='section-37.swift'/>
<documentation relative-path='section-37.html'/>
<code source-file-name='section-39.swift'/>
<documentation relative-path='section-39.html'/>
<code source-file-name='section-41.swift'/>
<documentation relative-path='section-41.html'/>
<code source-file-name='section-43.swift'/>
<documentation relative-path='section-43.html'/>
<code source-file-name='section-45.swift'/>
<documentation relative-path='section-45.html'/>
<code source-file-name='section-47.swift'/>
<documentation relative-path='section-47.html'/>
<code source-file-name='section-49.swift'/>
<documentation relative-path='section-49.html'/>
<code source-file-name='section-51.swift'/>
</sections>
<timeline fileName='timeline.xctimeline'/>
</playground>
File renamed without changes.
2 changes: 2 additions & 0 deletions Design-Patterns.playground/section-1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Swift
import Foundation
File renamed without changes.
5 changes: 5 additions & 0 deletions Design-Patterns.playground/section-11.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let uglierPoint = Point{
$0.x = 0.1
$0.y = 0.2
$0.z = 0.3
}
File renamed without changes.
24 changes: 24 additions & 0 deletions Design-Patterns.playground/section-13.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Number
{
var number:AnyObject

init(number:AnyObject){
self.number = number
}

convenience init(integer:Int){
self.init(number:integer)
}

convenience init(double:Double){
self.init(number:double)
}

func integerValue() -> Int{
return self.number as Int
}

func doubleValue() -> Double{
return self.number as Double
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions Design-Patterns.playground/section-15.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let number = Number(double: 12.1)
let double = number.doubleValue()
let integer = number.integerValue()
File renamed without changes.
13 changes: 13 additions & 0 deletions Design-Patterns.playground/section-17.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class ThieveryCorporationPersonDisplay{

var name:String?
let font:String

init(font:String){
self.font = font
}

func clone() -> ThieveryCorporationPersonDisplay{
return ThieveryCorporationPersonDisplay(font: self.font)
}
}
File renamed without changes.
10 changes: 10 additions & 0 deletions Design-Patterns.playground/section-19.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let Prototype = ThieveryCorporationPersonDisplay(font:"Ubuntu")

let Philippe = Prototype.clone()
Philippe.name = "Philippe"

let Christoph = Prototype.clone()
Christoph.name = "Christoph"

let Eduardo = Prototype.clone()
Eduardo.name = "Eduardo"
File renamed without changes.
42 changes: 42 additions & 0 deletions Design-Patterns.playground/section-21.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
protocol Currency {
func symbol() -> String
func code() -> String
}

class Euro : Currency {
func symbol() -> String {
return ""
}

func code() -> String {
return "EUR"
}
}

class UnitedStatedDolar : Currency {
func symbol() -> String {
return "$"
}

func code() -> String {
return "USD"
}
}

enum Country {
case UnitedStates, Spain, France, UK
}

class CurrencyFactory {
class func currencyForCountry(country:Country) -> Currency? {
switch country {
case .Spain, .France :
return Euro()
case .UnitedStates :
return UnitedStatedDolar()
default:
return nil
}

}
}
File renamed without changes.
6 changes: 6 additions & 0 deletions Design-Patterns.playground/section-23.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let noCurrencyCode = "No Currency Code Available"

CurrencyFactory.currencyForCountry(.Spain)?.code() ?? noCurrencyCode
CurrencyFactory.currencyForCountry(.UnitedStates)?.code() ?? noCurrencyCode
CurrencyFactory.currencyForCountry(.France)?.code() ?? noCurrencyCode
CurrencyFactory.currencyForCountry(.UK)?.code() ?? noCurrencyCode
File renamed without changes.
38 changes: 38 additions & 0 deletions Design-Patterns.playground/section-25.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Component
*/
protocol Shape {
func draw(fillColor:String)
}

/**
* Leafs
*/
class Square : Shape {
func draw(fillColor: String) {
print("Drawing a Square with color \(fillColor)")
}
}

class Circle : Shape {
func draw(fillColor: String) {
print("Drawing a circle with color \(fillColor)")
}
}

/**
* Composite
*/
class Whiteboard : Shape {
lazy var shapes = [Shape]()

init(_ shapes:[Shape]) {
self.shapes = shapes
}

func draw(fillColor:String) {
for shape in self.shapes {
shape.draw(fillColor)
}
}
}
File renamed without changes.
2 changes: 2 additions & 0 deletions Design-Patterns.playground/section-27.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var whiteboard = Whiteboard([Circle(), Square()])
whiteboard.draw("Red")
File renamed without changes.
14 changes: 14 additions & 0 deletions Design-Patterns.playground/section-29.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Eternal{

class func setObject(value: AnyObject!, forKey defaultName: String!){
let defaults:NSUserDefaults = NSUserDefaults.standardUserDefaults()
defaults.setObject(value,forKey:defaultName)
defaults.synchronize()
}

class func objectForKey(defaultName: String!) -> AnyObject!{
let defaults:NSUserDefaults = NSUserDefaults.standardUserDefaults()
return defaults.objectForKey(defaultName)
}

}
File renamed without changes.
10 changes: 10 additions & 0 deletions Design-Patterns.playground/section-3.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class SingletonClass {
class var shared : SingletonClass {

struct Static {
static let instance : SingletonClass = SingletonClass()
}

return Static.instance
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions Design-Patterns.playground/section-31.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Eternal.setObject("Disconnect me. I’d rather be nothing",forKey:"Bishop")

Eternal.objectForKey("Bishop")
File renamed without changes.
Loading

0 comments on commit d113c9e

Please sign in to comment.