[
  {
    "path": ".gitignore",
    "content": "# Xcode\n.DS_Store\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\n*.xcworkspace\n!default.xcworkspace\nxcuserdata\nprofile\n*.moved-aside\nDerivedData\n.idea/"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014 Daniel Pink\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# Swift Playgrounds\n\nSome experiments with Playgrounds in XCode 8.2 using the Swift programming language.\n\n## The Swift Programming Language Book\n\nI have been working through all the examples in the book Apple Inc. “The Swift Programming Language.” iBooks. https://itunes.apple.com/au/book/swift-programming-language/id881256329?mt=11. Each .playground file in the project relates to a chapter from the Swift Programming Language book.\n\nI have implemented this as a single XCode project that contains a playground file for each chapter of the language reference book. I'm finding it quite useful to have this project open when I am writing Swift code as I can use the project wide search functionality to lookup any Swift features or syntax that I am unsure about (so long as I can remember the words to look for)\n\nBelow is a list of each of the files within the project (this is also a list of the chapters of the book that I have worked through).\n\n- **A Swift Tour** contains the code from the \"Swift Tour\" chapter. It touches on most of the unusual features of the language and is easy to search through to find examples. It is a large file and does tend to give the swift interpreter a rather hard time.\n\nChapters from the Language guide. Each chapter goes into depth about its particular subject.\n\n- **The Basics** This chapter covers basic value types like Strings, Ints, Bools and floats. The notation for exponent values in float literals is interesting. Comments are covered (nested /* */ comment blocks). TypeAlias is covered as are tuples. Optionals are touched on and assertions are mentioned.\n- **Basic Operators** Arithmetic, remainder, increment, decrement, comparison, unary, ternary, range (closed and half-closed) and logical operators. There are examples of all of them.\n- **Strings And Characters** Some details about Unicode literals (multi-byte characters). The countElements() function for finding the length of a string. Concatenating strings, Comparing strings and Interpolating strings (not much on splitting or parsing strings). \n- **Collection Types**\n- **ControlFlow**\n- **Functions**\n- **Closures**\n- **Enumerations**\n- **Classes And Structures**\n- **Properties**\n- **Methods**\n- **Subscripts**\n- **Inheritance**\n- **Initialization**\n- **Deinitialization**\n- **Automatic Reference Counting**\n- **Optional Chaining**\n- **Type Casting**\n- **Nested Types**\n- **Extensions**\n- **Protocols**\n- **Generics**\n- **Advanced Operators**\n\n\n## Using Swift with Cocoa and Objective-C Book\nThere are six playground files that work through the code in the “Using Swift with Cocoa and Objective-C.” iBook. https://itunes.apple.com/au/book/using-swift-cocoa-objective/id888894773?mt=11. They are listed below. The example from this book didn't translate as well to the playgrounds as the previous book examples did. \n\n- **Basic Setup**\n- **Interacting With Objective-C-**\n- **Writing Classes With Objective C Behaviour**\n- **Working With Cocoa Data Types**\n- **Adopting Cocoa Design Patterns**\n- **InteractingWith C**\n\n\n## Swift Standard Library\nThe documentation for the Swift Standard Library can be found at the following link https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/SwiftStandardLibraryReference/. There is a wealth of information contained in the standard library doc and it is nicely organised so that it is easy to experiment with in a playground environment. I have attempted to extend the examples somewhat to try and show off some of the other features of the standard library.\n\n- **String**\n- **Array**\n- **Dictionary**\n- **NumericTypes**\n- **Protocols**\n- **FreeFunctions**\n- **Undocumented**\n\n## Swift Blog\nThe Swift blog contains several articles detailing interesting information about the developing language. \n\n- **2014-08-15 Value and Reference Types**\n- **2014-08-05 Boolean**\n- **2014-07-28 Interacting with C Pointers**\n- **2014-07-23 Access Control**\n\n## NSHipster\nLots of great articles delving into the finer points of Cocoa programming. The recent articles on Swift are always interesting to go through\n\n- **2014-08-08 Swift Literal Convertibles** Shows how you can create types of your own that can be written as literals when you use them. \n\n# What next?\nHere are some links to other projects around the web that I would also like to implement\n- **Peter Norvig** has some great posts that delve into various programming topics. Mostly they are in Python though so it would be interesting to implement them in Swift.\n\t- http://norvig.com/spell-correct.html http://airspeedvelocity.net/2015/05/02/spelling/\n\t- http://nbviewer.ipython.org/url/norvig.com/ipython/TSPv3.ipynb\n- **Erica Sandun** Has a book out and also publishes a lot of information about Swift Playgrounds. In particular she is able to get impressive graphics, windows and user inputs to work, which is something that I haven't figured out yet.\n\t- http://ericasadun.com/2015/05/04/swift-using-functions-to-initialize-view-types/\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/2014-08-08-LockingInSwift.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/2014-08-08-LockingInSwift.playground/section-1.swift",
    "content": "// Locking in Swift blog post by John Gallagher\n// http://www.bignerdranch.com/blog/locking-in-swift-helping-protect-me-from-myself/\n\nimport Cocoa\nimport Foundation\nimport dispatch\n\n\n// The Setup\n// Writing a class that includes an array of things and a timestamp of when the array was last modified.\n/*\nclass ArrayTracker<T> {\n    private var things: [T] = []\n    private var lastModified: NSDate? // Why is this optional?\n    \n    func appendToThings(item: T) -> (NSDate, Int) {\n        things.append(item)\n        lastModified = NSDate.date()\n        return (lastModified!, things.count)\n    }\n    \n    func lastModifiedDate() -> NSDate? {\n        return lastModified\n    }\n}\n\nvar a: ArrayTracker = ArrayTracker<Int>()\n\nlet (l1, c1) = a.appendToThings(1234)\nl1\nc1\na.appendToThings(5678)\na.appendToThings(4)\n*/\n\n/*\n// The Lock\n// We want a readers-writer lock. Multiple readers can access the lock concurrently but only a single writer can have access at a time.\nprotocol ReadWriteLock {\n    // Get a shared reader lock, run the given block, and unlock\n    mutating func withReadLock(block: () -> ())\n    \n    // get an exclusive writer lock, run the given block, and unlock\n    mutating func withWriteLock(block: () -> ())\n}\n\nstruct MyLock: ReadWriteLock {\n    let queue = dispatch_queue_create(\"readWriteLock\", dispatch.DISPATCH_QUEUE_CONCURRENT)\n    mutating func withReadLock(block: () -> ()) {\n        dispatch_async(queue, block)\n    }\n    mutating func withWriteLock(block: () -> ()) {\n        dispatch_barrier_async(queue, block)\n    }\n}\n\nclass ArrayTracker<T> {\n    private var things: [T] = []\n    private var lock: ReadWriteLock = MyLock()\n    private var lastModified: NSDate?\n    \n    func lastModifiedDate() -> NSDate? {\n        var date: NSDate?\n        \n        // withReadLock runs the block its given synchronously, so we don't need to capture self - use unowned\n        lock.withReadLock { [unowned self] in\n            date = self.lastModified\n        }\n        return date\n    }\n    \n    func appendToThings(item: T) -> (NSDate, Int) {\n        var date: NSDate!\n        var count: Int!\n        lock.withWriteLock { [unowned self] in\n            self.things.append(item)\n            self.lastModified = NSDate.date()\n            date = self.lastModified\n            count = self.things.count\n        }\n        return (date, count)\n    }\n}\n*/\n\n\nlet address = 0xFFFE\naddress % 0xFFFF\n\n\n\nprotocol ReadWriteLock {\n    // Get a shared reader lock, run the given block, unlock, and return whatever the block returned\n    mutating func withReadLock<T>(block: () -> T) -> T\n    \n    // Get an exclusive writer lock, run the given block, unlock, and return whatever the block returned\n    mutating func withWriteLock<T>(block: () -> T) -> T\n}\n/*\nstruct MyLock: ReadWriteLock {\n    let queue = dispatch_queue_create(\"readWriteLock\", dispatch.DISPATCH_QUEUE_CONCURRENT)\n    mutating func withReadLock<T>(block: () -> T) -> T {\n        var result: T\n        dispatch_sync(queue) {\n            result = block()\n        }\n        return result\n    }\n    mutating func withWriteLock<T>(block: () -> T) -> T {\n        var result: T\n        dispatch_barrier_sync(queue) {\n            result = block()\n        }\n        return result\n    }\n}\n\nclass ArrayTracker<T> {\n    private var things: [T] = []\n    private var lock: ReadWriteLock = MyLock()\n    private var lastModified: NSDate?\n    \n    func lastModifiedDate() -> NSDate? {\n        // return the result of the call to withReadLock...\n        return lock.withReadLock { [unowned self] in\n            // ... which is the date that we want\n            return self.lastModified\n        }\n    }\n    \n    func appendToThings(item: T) -> (NSDate, Int) {\n        return lock.withWriteLock { [unowned self] in\n            self.things.append(item)\n            self.lastModified = NSDate.date()\n            return (self.lastModified!, self.things.count)\n        }\n    }\n}\n\n*/\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/2014-08-08-LockingInSwift.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/NSHipster/2014-08-18-SwiftLiteralConvertibles.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/NSHipster/2014-08-18-SwiftLiteralConvertibles.playground/section-1.swift",
    "content": "// Swift Literal Convertibles from NSHipster http://nshipster.com/swift-literal-convertible/\n\nimport Foundation\n\n/*\nenum Optional<T> : Reflectable, NilLiteralConvertible {\n    case None\n    case Some(T)\n    init()\n    init(_ some: T)\n    var hasValue: Bool { get }\n    \n    func map<U>(f: (T) -> U) -> U?\n    func getMirror() -> MirrorType\n    static func convertFromNilLiteral() -> T?\n}\n*/ // Doesn't seem to work\n\nstruct Regex {\n    let pattern: String\n    let options: NSRegularExpressionOptions!\n    \n    private var matcher: NSRegularExpression {\n        return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil)\n    }\n    \n    init(pattern: String, options: NSRegularExpressionOptions = nil) {\n        self.pattern = pattern\n        self.options = options\n    }\n    \n    func match(string: String, options: NSMatchingOptions = nil) -> Bool {\n        return self.matcher.numberOfMatchesInString(string, options: options, range: NSMakeRange(0, string.utf16Count)) != 0\n    }\n}\n\nextension Regex: StringLiteralConvertible {\n    typealias ExtendedGraphemeClusterLiteralType = StringLiteralType\n    \n    static func convertFromExtendedGraphemeClusterLiteral(value: ExtendedGraphemeClusterLiteralType) -> Regex {\n        return self(pattern: value)\n    }\n    \n    static func convertFromStringLiteral(value: StringLiteralType) -> Regex {\n        return self(pattern: value)\n    }\n}\n\nlet string: String = \"foo bar baz\"\nlet regex: Regex = \"foo\"\nregex.match(string)\n\n\"foo\".match(string)\n\n\n\n// ArrayLiteralConvertible and Sets\nstruct Set<T: Hashable> {\n    typealias Index = T\n    private var dictionary: [T: Bool]\n    \n    init() {\n        self.dictionary = [T: Bool]()\n    }\n    \n    var count: Int {\n        return self.dictionary.count\n    }\n    \n    var isEmpty: Bool {\n        return self.dictionary.isEmpty\n    }\n    \n    func contains(element: T) -> Bool {\n        return self.dictionary[element] ?? false\n    }\n    \n    mutating func put(element: T) {\n        self.dictionary[element] = true\n    }\n    \n    mutating func remove(element: T) -> Bool {\n        if self.contains(element) {\n            self.dictionary.removeValueForKey(element)\n            return true\n        } else {\n            return false\n        }\n    }\n}\n\nvar basicSet: Set<Int> = Set()\nbasicSet.put(1)\nbasicSet.put(2)\nbasicSet.put(3)\nbasicSet.contains(1)\nbasicSet.count\n\nextension Set: ArrayLiteralConvertible {\n    static func convertFromArrayLiteral(elements: T...) -> Set<T> {\n        var set = Set<T>()\n        for element in elements {\n            set.put(element)\n        }\n        return set\n    }\n}\n\nlet set: Set = [1, 2, 3]\nset.contains(1)\nset.count\n\n\n\n// StringLitralConvertible and URLs\nextension NSURL: StringLiteralConvertible {\n    public class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self {\n        return self(string: value)\n    }\n    \n    public class func convertFromStringLiteral(value: String) -> Self {\n        return self(string: value)\n    }\n}\n\n\"http://nshipster.com/\".host\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/NSHipster/2014-08-18-SwiftLiteralConvertibles.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-23-AccessControl.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-23-AccessControl.playground/section-1.swift",
    "content": "// Playground - noun: a place where people can play\n\nimport Cocoa\nimport Foundation\n\npublic class ListItem {\n    \n    // Public properties.\n    public var text: String\n    public var isComplete: Bool\n    \n    // Readable throughout the module, but only writable from within this file.\n    private(set) var UUID: NSUUID\n    \n    public init(text: String, completed: Bool, UUID: NSUUID) {\n        self.text = text\n        self.isComplete = completed\n        self.UUID = UUID\n    }\n    \n    // Usable within the framework target, but not by other targets.\n    func refreshIdentity() {\n        self.UUID = NSUUID()\n    }\n    \n    public func isEqual(object: AnyObject?) -> Bool {\n        if let item = object as? ListItem {\n            return self.UUID == item.UUID\n        }\n        return false\n    }\n}\n\nlet item1 = ListItem(text: \"Item 1\", completed: false, UUID: NSUUID())\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-23-AccessControl.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-28-InteractingWithCPointers.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-28-InteractingWithCPointers.playground/section-1.swift",
    "content": "// Playground - noun: a place where people can play\n\nimport Cocoa\nimport CoreGraphics\nimport XCPlayground\nimport Accelerate\n\nvar color = NSColor.magentaColor()\nvar r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0\ncolor.getRed(&r, green: &g, blue: &b, alpha: &a)\n\nvar maybeError: NSError?\nif let contents = NSFileManager.defaultManager().contentsOfDirectoryAtPath(\"/usr/bin\", error: &maybeError) {\n    println(\"\\(contents)\")\n} else if let error = maybeError {\n    println(\"\\(error)\")\n}\n\n\nlet x: [Float] = [1, 2, 3, 4]\nlet y: [Float] = [0.5, 0.25, 0.125, 0.0625]\nvar result:[Float] = [0, 0, 0, 0]\n\nvDSP_vadd(x, 1, y, 1, &result, 1, 4)\nresult\n\nputs(\"Hello fromlibc\")\nlet fd = open(\"/tmp/scratch.txt\", O_WRONLY|O_CREAT, 0o666)\nif fd < 0 {\n    perror(\"could not open /tmp/scratch.txt\")\n} else {\n    let text = \"Hello World\"\n    write(fd, text, strlen(text))\n    close(fd)\n}\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-07-28-InteractingWithCPointers.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-05-Boolean.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-05-Boolean.playground/section-1.swift",
    "content": "// Playground - noun: a place where people can play\n\nimport Cocoa\n\nenum MyBool {\n    case myTrue, myFalse\n}\nvar a: MyBool = MyBool.myTrue\n\nextension MyBool {\n    init() { self = .myFalse }\n}\nvar b: MyBool = MyBool()\n\nextension MyBool : BooleanLiteralConvertible {\n    static func convertFromBooleanLiteral(value: Bool) -> MyBool {\n        return value ? myTrue : myFalse\n    }\n}\nvar c: MyBool = true\n\nextension MyBool : BooleanType {\n    var boolValue: Bool {\n        get {\n            switch self {\n            case .myTrue: return true\n            case .myFalse: return false\n            }\n        }\n    }\n}\nif a { println(\"a is true\") }\n\nextension MyBool {\n    //MyBool can be constructed from BooleanType\n    init(_ v : BooleanType) {\n        if v.boolValue {\n            self = .myTrue\n        } else {\n            self = .myFalse\n        }\n    }\n}\nvar basicBool:Bool = false\na = MyBool(basicBool)\nif a { println(\"a is true\") } else { println(\"a is false\") }\n\n/*\n//  Simple enums that have no associated data (like MyBool) are automatically made Equatable by the compiler, so no additional code is required.\nextension MyBool : Equatable {\n}\nfunc ==(lhs: MyBool, rhs: MyBool) -> Bool {\n    switch (lhs, rhs) {\n    case (.myTrue, .myTrue), (.myFalse, .myFalse):\n        return true\n    default:\n        return false\n    }\n}\n*/\nif a == a { println(\"a == a\") }\nif a != a { } else { println(\"!(a != a)\") }\n\n// Binary operations\nfunc &(lhs:MyBool, rhs: MyBool) -> MyBool {\n    if lhs {\n        return rhs\n    }\n    return false\n}\nfunc |(lhs: MyBool, rhs: MyBool) -> MyBool {\n    if lhs {\n        return true\n    }\n    return rhs\n}\nfunc ^(lhs: MyBool, rhs: MyBool) -> MyBool {\n    return MyBool(lhs != rhs)\n}\na & b\nb | c\nc ^ a\n\nprefix func !(a: MyBool) -> MyBool {\n    return a ^ true\n}\n// Compound assignment (with bitwise and)\nfunc &=(inout lhs: MyBool, rhs: MyBool) {\n    lhs = lhs & rhs\n}\n!a\na &= b\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-05-Boolean.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-15-ValueAndReferenceTypes.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-15-ValueAndReferenceTypes.playground/section-1.swift",
    "content": "// Value and Reference Types\n\nimport Foundation\n\n// Value type example\nstruct S { var data: Int = -1 }\nvar a = S()\nvar b = a                       // a is copied to b\na.data = 42                     // Changes a, not b\nprintln(\"\\(a.data), \\(b.data)\")\n\n\n// Reference type example\nclass C { var data: Int = -1 }\nvar x = C()\nvar y = x                       // x is copied to y\nx.data = 42                     // changes the instance referred to by x (and y)\nprintln(\"\\(x.data), \\(y.data)\")\n\n\n// Use a value type when:\n// - Comparing instance data with == makes sense\n// - You want copies to have independent state\n// - The data will be used in code across multiple threads\n\n// Use a reference type when:\n// - Comparing instance identity with === makes sense\n// - You want to create shared, mutable state\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-15-ValueAndReferenceTypes.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-27-OptionalCaseStudy-valuesForKeys.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-27-OptionalCaseStudy-valuesForKeys.playground/section-1.swift",
    "content": "// Optional Case Study: valuesForKeys\n\nimport Foundation\n\n/*\nextension Dictionary {\n    func valuesForKeys(keys: [K], notFoundMarkery: V) -> [V] {\n        // to be implemented\n    }\n}\n*/\n\n/* Beta 6 seems to report that .reserve doesn't exist?\nextension Dictionary {\n    func valuesForKeys(keys: [Key]) -> [Value?] {\n            var result = [Value?]()\n            result.reserve(keys.count)\n            for key in keys {\n                result.append(self[key])\n            }\n        return result\n    }\n}\n*/\n\nextension Dictionary {\n    func valuesForKeys(keys: [Key]) -> [Value?] {\n        return keys.map { self[$0] }\n    }\n}\n\nlet dict = [\"A\": \"Amir\", \"B\": \"Bertha\", \"C\": \"Ching\"]\ndict.valuesForKeys([\"A\", \"C\"])\ndict.valuesForKeys([\"B\", \"D\"])\n\n\n\n// Nested Optionals\ndict.valuesForKeys([\"A\", \"C\"]).last\ndict.valuesForKeys([\"B\", \"D\"]).last\ndict.valuesForKeys([]).last\n\n\n\n// Providing a Default\nextension Dictionary {\n    func valuesForKeys(keys: [Key], notFoundMarker: Value) -> [Value] {\n        return self.valuesForKeys(keys).map { $0 ?? notFoundMarker }\n    }\n}\n\ndict.valuesForKeys([\"B\", \"D\"], notFoundMarker: \"Anonymous\")\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Blogs/Swift Blog/2014-08-27-OptionalCaseStudy-valuesForKeys.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>${PRODUCT_NAME}</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n\t<key>LSMinimumSystemVersion</key>\n\t<string>${MACOSX_DEPLOYMENT_TARGET}</string>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>Copyright © 2014 Electronic Innovations. All rights reserved.</string>\n\t<key>NSMainNibFile</key>\n\t<string>MainMenu</string>\n\t<key>NSPrincipalClass</key>\n\t<string>NSApplication</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "Swift-Playgrounds/Others/2014-08-11-SwiftOperators.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Others/2014-08-11-SwiftOperators.playground/section-1.swift",
    "content": "// Swift Operators - http://nshipster.com/swift-operators/\n\nimport Cocoa\n\n// Overloading\n\nfunc * (left: String, right: Int) -> String {\n    if right <= 0 {\n        return \"\"\n    }\n    \n    var result = left\n    for _ in 1..<right {\n        result += left\n    }\n    \n    return result\n}\n\n\"a\" * 6\n\n// overloading can be used for evil\n[1, 2] + [3, 4]\n\nfunc +(left: [Double], right: [Double]) -> [Double] {\n    var sum = [Double](count: left.count, repeatedValue: 0.0)\n    for (i, _) in enumerate(left) {\n        sum[i] = left[i] + right[i]\n    }\n    \n    return sum\n}\nprintln(\"\\([1, 2] + [3, 4])\")\n\nfunc +(left: [Int], right: [Int]) -> [Int] {\n    var sum = [Int](count: left.count, repeatedValue: 0)\n    for (i, _) in enumerate(left) {\n        sum[i] = left[i] + right[i]\n    }\n    \n    return sum\n}\n\nprintln(\"\\([1, 2] + [3, 4])\")\n\n\n// I'm specifically concerned about the semantics of array operators, as demonstrated in the previous example. My 2 cents: arrays should forego the + and - operators in lieu of <<:\n\nfunc <<<T> (inout left: [T], right: [T]) -> [T] {\n    //left.extend(right)\n    return left\n}\n\nfunc <<<T> (inout left: [T], right: T) -> [T] {\n    //left.append(right)\n    return left\n}\n\n//[1,2,3,4]<<[5,6]\n//[1,2,3,4]<<5\n\n\n// Custom Operators\ninfix operator ** { associativity left precedence 160 }\nfunc ** (left: Double, right: Double) -> Double {\n    return pow(left, right)\n}\n\n2 ** 3 // 8\n\n// When creating custom operators, make sure to also create the corresponding assignment operator, if appropriate:\n\ninfix operator **= { associativity right precedence 90 }\nfunc **= (inout left: Double, right: Double) {\n    left = left ** right\n}\n\n\n// Custom Operators with Protocol and Method\n// First, a RegularExpressionMatchable protocol is declared, with a single method for matching regular expressions.\nprotocol RegularExpressionMatchable {\n    func match(pattern: String, options: NSRegularExpressionOptions) -> Bool\n}\n\n// Next, an extension adding conformance to this protocol to String is declared, with a provided implementation of match, using NSRegularExpression.\nextension String: RegularExpressionMatchable {\n    func match(pattern: String, options: NSRegularExpressionOptions = nil) -> Bool {\n        let regex = NSRegularExpression(pattern: pattern, options: nil, error: nil)\n        return regex.numberOfMatchesInString(self, options: nil, range: NSMakeRange(0, self.utf16Count)) != 0\n    }\n}\n\n// Finally, the =~ operator is declared and implemented on a generic type conforming to RegularExpressionMatchable.\ninfix operator =~ { associativity left precedence 130 }\nfunc =~<T: RegularExpressionMatchable> (left: T, right: String) -> Bool {\n    return left.match(right, options: nil)\n}\n\n// By doing this, a user has the option to use the match function instead of the operator. It also has the added benefit of greater flexibility in what options are passed into the method.\n\n\n// Use of Mathematical Symbols\nprefix operator √ {}\nprefix func √ (number: Double) -> Double {\n    return sqrt(number)\n}\n√16\n√2\n\ninfix operator ± { associativity left precedence 140 }\nfunc ± (left: Double, right: Double) -> (Double, Double) {\n    return (left + right, left - right)\n}\n\nprefix operator ± {}\nprefix func ± (value: Double) -> (Double, Double) {\n    return 0 ± value\n}\n\n2 ± 3\n±4\n\n\n\n// Guidelines for Swift Operators\n\n// Don't create an operator unless its meaning is obvious and undisputed. Seek out any potential conflicts to ensure semantic consistency.\n// Custom operators should only be provided as a convenience. Complex functionality should always be implemented in a function, preferably one specified as a generic using a custom protocol.\n// Pay attention to the precedence and associativity of custom operators. Find the closest existing class of operators and use the appropriate precedence value.\n// If it makes sense, be sure to implement assignment shorthand for a custom operator (e.g. += for +).\n"
  },
  {
    "path": "Swift-Playgrounds/Others/2014-08-11-SwiftOperators.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday-Alternative-1.playground/Contents.swift",
    "content": "// When is Cheryl's Birthday\n// adapted from Peter Norvig's code in http://nbviewer.ipython.org/url/norvig.com/ipython/Cheryl.ipynb\n\nimport Cocoa\n\n// 1. Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is. Cheryl gave them a list of 10 possible dates:\n//       May 15       May 16       May 19\n//      June 17      June 18\n//      July 14      July 16\n//    August 14    August 15    August 17\n\n// 2. Cheryl then tells Albert and Bernard seperately the month and day of the birthday respectively.\n// 3. Albert  : I don't know when Cheryl's birthday is, but I know that Bernard does not know too.\n// 4. Bernard : At first I don't know when Cheryl's birthday is, but I know now.\n// 5. Albert  : Then I also know when Cheryls birthday is.\n\n// So when is Cheryl's Birthday?\n\nlet dates = [\"May 15\",    \"May 16\",                            \"May 19\",\n                                      \"June 17\",   \"June 18\",\n    \"July 14\",           \"July 16\",\n    \"August 14\", \"August 15\", \"August 17\"]\n\nfunc Month(date: String) -> String {\n    return date.componentsSeparatedByString(\" \")[0]\n}\nMonth(\"May 15\")\n\nfunc Day(date: String) -> String {\n    return date.componentsSeparatedByString(\" \")[1]\n}\nDay(\"May 15\")\n\nfunc tell(part: String, possibleDates: [String]) -> [String] {\n    return possibleDates.filter(){ $0.rangeOfString(part) != nil }\n}\ntell(\"May\", possibleDates: dates)\ntell(\"15\", possibleDates: dates)\ntell(\"18\", possibleDates: dates)\n\nfunc know(possibleDates: [String]) -> Bool {\n    return possibleDates.count == 1\n}\nknow(tell(\"15\", possibleDates: dates))\n\n// Overall Strategy\n// When Cheryl tells Albert \"May\" then he knows there are three possibilities, but we (the puzzle solvers) don't, because we don't know what Cheryl said. So what can we do? We will consider all of the possible dates, one at a time. For example, first consider \"May 15\". Cheryl tells Albert \"May\" and Bernard \"15\", giving them the lists of possible birthdates shown above. We can then check whether statements 3 through 5 are true in this scenario. If they are, then \"May 15\" is a solution to the puzzle. Repeat the process for each of the possible dates. If all goes well, there should be exactly one solution.\n\nfunc not(value: Bool) -> Bool { return !value }\n\n// Bernard: I don't know when Cheryl's birthday is.\n// Albert: I don't know when Cheryl's birthday is, but I know that Bernard doesn't know too [because he just said so].\n// Bernard: At first I didn't know when Cheryl's birthday is, but I know now.\n// Albert: Then I also know when Cheryl's birthday is.\n\n// Bernard: I don't know when Cheryl's birthday is.\nfunc statement2(date: String) -> Bool {\n    let bernardPossibleDates = tell(Day(date), possibleDates: dates)\n    return not(know(bernardPossibleDates))\n}\nlet statementTwo = dates.filter(statement2)\n\n\n/// Albert: I don't know when Cheryl's birthday is, but I know that Bernard doesn't know too [because he just said so].\nfunc statement3(date: String) -> Bool {\n    let albertPossibleDates = tell(Month(date), possibleDates: dates)\n    return not(know(albertPossibleDates)) && not(know(albertPossibleDates.filter(statement2)))}\nlet statementThree = dates.filter(statement3)\n\n\n// Bernard: At first I didn't know when Cheryl's birthday is, but I know now.\nfunc statement4(date: String) -> Bool {\n    let atFirst = tell(Day(date), possibleDates: dates)\n    //println(\"\\(not(know(atFirst))),\\(know(filter(atFirst, statement3)))\")\n    return not(know(atFirst)) && know(atFirst.filter(statement3))\n}\nlet statementFour = dates.filter(statement4)\n// The dates which satisfy both statement 3 and 4 are\n//let statementThreeAndFour = filter(statementThree, statement4)\n\n\n// Albert: Then I also know when Cheryl's birthday is\nfunc statement5(date: String) -> Bool {\n    let months = tell(Month(date), possibleDates: dates)\n    return know(months.filter(statement4))\n}\nlet statementFive = dates.filter(statement5)\n\n\nfunc statements3to5(date: String) -> Bool {\n    return statement2(date) && statement3(date) && statement4(date) && statement5(date)\n}\nfunc cherylsBirthday(possibleDates: [String]) -> [String]\n"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday-Alternative-1.playground/Sources/SupportCode.swift",
    "content": "//\n// This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Cheryls-Birthday-Alternative-1.playground.\n//\n"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday-Alternative-1.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx' requires-full-environment='true'/>"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday.playground/Contents.swift",
    "content": "// When is Cheryl's Birthday\n// adapted from Peter Norvig's code in http://nbviewer.ipython.org/url/norvig.com/ipython/Cheryl.ipynb\n\nimport Cocoa\n\n// 1. Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is. Cheryl gave them a list of 10 possible dates:\n//       May 15       May 16       May 19\n//      June 17      June 18\n//      July 14      July 16\n//    August 14    August 15    August 17\n\n// 2. Cheryl then tells Albert and Bernard seperately the month and day of the birthday respectively.\n// 3. Albert  : I don't know when Cheryl's birthday is, but I know that Bernard does not know too.\n// 4. Bernard : At first I don't know when Cheryl's birthday is, but I know now.\n// 5. Albert  : Then I also know when Cheryls birthday is.\n\n// So when is Cheryl's Birthday?\n\nlet dates = [\"May 15\",    \"May 16\",    \"May 19\",\n            \"June 17\",   \"June 18\",\n            \"July 14\",   \"July 16\",\n          \"August 14\", \"August 15\", \"August 17\"]\n\nfunc Month(date: String) -> String {\n    return date.componentsSeparatedByString(\" \")[0]\n}\nMonth(\"May 15\")\n\nfunc Day(date: String) -> String {\n    return date.componentsSeparatedByString(\" \")[1]\n}\nDay(\"May 15\")\n\nfunc tell(part: String, possibleDates: [String]) -> [String] {\n    return possibleDates.filter(){ $0.rangeOfString(part) != nil }\n}\ntell(\"May\", possibleDates: dates)\ntell(\"15\", possibleDates: dates)\n\nfunc know(possibleDates: [String]) -> Bool {\n    return possibleDates.count == 1\n}\nknow(tell(\"15\", possibleDates: dates))\n\n// Overall Strategy\n// When Cheryl tells Albert \"May\" then he knows there are three possibilities, but we (the puzzle solvers) don't, because we don't know what Cheryl said. So what can we do? We will consider all of the possible dates, one at a time. For example, first consider \"May 15\". Cheryl tells Albert \"May\" and Bernard \"15\", giving them the lists of possible birthdates shown above. We can then check whether statements 3 through 5 are true in this scenario. If they are, then \"May 15\" is a solution to the puzzle. Repeat the process for each of the possible dates. If all goes well, there should be exactly one solution.\n\nfunc not(value: Bool) -> Bool { return !value }\n\n\n// Albert: After Cheryl told me the month of her birthdate, I didn't know her birthday. I don't know which day Cheryl told Bernard, but I know that for all of the possible dates, if Bernard is told that day, he wouldn't know the birthdate.\nfunc statement3(date: String) -> Bool {\n    let albertPossibleDates = tell(Month(date), possibleDates: dates)\n    var result = not(know(albertPossibleDates)) // Confirm that Albert doesn't know the date\n    for d in albertPossibleDates {\n        result = result && not(know(tell(Day(d), dates)))\n    }\n    return result\n}\nstatement3(\"May 15\")\nlet statementThree = dates.filter(statement3)\nprint(\"Dates satisfied by Statement 3: \\(statementThree)\")\n\n\n// Bernard: At first Cheryl told me the day, and I didn't know. Then I considered just the dates for which Albert's statement3 is true, and now I know.\nfunc statement4(date: String) -> Bool {\n    let atFirst = tell(Day(date), possibleDates: dates)\n    return not(know(atFirst)) && know(atFirst.filter(statement3))\n}\n// The dates which satisfy both statement 3 and 4 are\nlet statementThreeAndFour = statementThree.filter(statement4)\nprint(\"Dates satisfied by Statement 3 & 4: \\(statementThreeAndFour)\")\n\n\n// Albert: Then I also know when Cheryl's birthday is\nfunc statement5(date: String) -> Bool {\n    let months = tell(Month(date), possibleDates: dates)\n    return know(months.filter(statement4))\n}\nstatement5(\"May 15\")\nlet statementFive = dates.filter(statement5)\nprint(\"Dates satisfied by Statement 5: \\(statementFive)\")\n\nfunc statements3to5(date: String) -> Bool {\n    return statement3(date) && statement4(date) && statement5(date)\n}\nfunc cherylsBirthday(possibleDates: [String]) -> [String] {\n    return possibleDates.filter\n"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday.playground/Sources/SupportCode.swift",
    "content": "//\n// This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to Cheryls-Birthday.playground.\n//\n"
  },
  {
    "path": "Swift-Playgrounds/Others/Cheryls-Birthday.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx' requires-full-environment='true'/>"
  },
  {
    "path": "Swift-Playgrounds/Others/WritingSwiftClassesWithObjectiveCBehaviour.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='iphonesimulator' runInFullSimulator='YES'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Others/WritingSwiftClassesWithObjectiveCBehaviour.playground/section-1.swift",
    "content": "// Writing Swift Classes with Objective-C Behaviour\n\n//  You can \n//   - subclass Objective-C classes, \n//   - adopt Objective-C protocols, \n//   - take advantage of other Objective-C functionality \n//  when writing a Swift class.\n\n\n// Inheriting from Objecive-C Classes\nimport UIKit\n\nclass MySwiftViewController: UIViewController {\n    \n}\n\n\n// Adopting Protocols\n/*\nclass AnotherSwiftViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {\n    \n}\n*/\n\n\n// Interacting with Interface Builder\n// Working with Oulets and Actions\n//\n//  When you declare an outlet in Swift, \n//  - the compiler automatically converts the type to a weak implicitly unwrapped optional\n//  - assigns it an initial value of nil\n\n//  The compiler replaces @IBOutlet var name: Type with @IBOutlet weak var name: Type! = nil. \n//  The compiler converts the type to an implicitly unwrapped optional so that you aren’t required to assign a value in an initializer. It is implicitly unwrapped because after your class is initialized from a storyboard or xib file, you can assume that the outlet has been connected. Outlets are weak by default because the outlets you create usually have weak relationships.\nclass YetAnotherSwiftViewController: UIViewController {\n    @IBOutlet var button: UIButton!\n    //@IBOutlet var textFields: [UITextField]\n    @IBAction func buttonTapped(_: AnyObject) {\n        print(\"button tapped!\")\n    }\n}\n\n\n// Live Rendering\n//  @IBDesignable, allows for live rendering of a custom view in IB\n//  When you create a custom view that inherits from UIView or NSView, you can add the @IBDesignable attribute just before the class declaration. After you add the custom view to Interface Builder (by setting the custom class of the view in the inspector pane), Interface Builder renders your view in the canvas.\n//  @IBInspectable, allows you to change property values of your custom classes from IB\n//  You can also add the @IBInspectable attribute to properties with types compatible with user defined runtime attributes. After you add your custom view to Interface Builder, you can edit these properties in the inspector.\n@IBDesignable\nclass DesignableCustomView: UIView {\n    @IBInspectable var textColor: UIColor = UIColor(hue: 0.0, saturation: 0.9, brightness: 0.8, alpha: 1.0)\n    @IBInspectable var iconHeight: CGFloat = 0.0\n}\n\n\n// Specifying Property Attributes\n// Swift properties are strong by default. Use the weak keyword if required. Weak properties must be optional class types.\n// There are no readwrite and readonly attributes in swift. Use let for read only and var for read/write properties.\n// In Swift, the Objective-C copy property attribute translates to @NSCopying.\n\n\n// Implementing Core Data Managed Object Subclasses\n// “Add the @NSManaged attribute before each property definition in your managed object subclass that corresponds to an attribute or relationship in your Core Data model. Like the @dynamic attribute in Objective-C, the @NSManaged attribute informs the Swift compiler that the storage and implementation of a property will be provided at runtime.\n\n\n\n\n\n\nvar textColor: UIColor = UIColor(hue: 0.0, saturation: 0.9, brightness: 0.8, alpha: 1.0)\nvar textColorArray: [UIColor] = []\nfor i in 0..<10 {\n    let sat = 0.1 * Float(i)\n    var textColor: UIColor = UIColor(hue: CGFloat(sat), saturation: 0.7, brightness: 0.5, alpha: 0.9)\n    textColorArray.append(textColor)\n}\ntextColorArray\n\n"
  },
  {
    "path": "Swift-Playgrounds/Others/WritingSwiftClassesWithObjectiveCBehaviour.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/GameDevUniversity.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/GameDevUniversity.playground/section-1.swift",
    "content": "// Example from http://gamedevuniversity.com/swift-playground-spritekit/\n\n// Import SpriteKit API and XCPlayground\nimport SpriteKit\nimport XCPlayground\n\n// Extend the SKScene to create a new Scene\nclass GameScene:SKScene {\n    \n    required init(coder: NSCoder!) {\n        super.init(coder: coder)\n    }\n    \n    override init(size: CGSize) {\n        super.init(size: size)\n    }\n    \n    override func didMoveToView(view: SKView!) {\n        \n        // Create an Array of SKSprite\n        var monsters = [SKSpriteNode]()\n        \n        // Load SKSprite to the array\n        // Append is similar to Array push()\n        // Note that resources in Playground are imported using their full path\n        \n        // Creative Commons – Attribution (CC BY 3.0) Monster designed by Ana Lourenço from the Noun Project\n        // http://thenounproject.com/term/monster/56811/\n        monsters.append(SKSpriteNode(imageNamed: \"/Users/danielpi/repos/Swift-Playgrounds/Swift-Playgrounds/SpriteKit/icon_56811.png\"))\n        monsters.append(SKSpriteNode(imageNamed: \"/Users/danielpi/repos/Swift-Playgrounds/Swift-Playgrounds/SpriteKit/icon_56811.png\"))\n        monsters.append(SKSpriteNode(imageNamed: \"/Users/danielpi/repos/Swift-Playgrounds/Swift-Playgrounds/SpriteKit/icon_56811.png\"))\n        \n        \n        // Loop through SKSprite array\n        for var i=0; i<3; i++ {\n            \n            var monster = monsters[i]\n            \n            // Position the Sprite randomly\n            var xPos = CGFloat(UInt(arc4random()) % (500 - UInt(monster.size.width)) + UInt(monster.size.width) / 2)\n            var yPos = CGFloat(UInt(arc4random()) % (500 - UInt(monster.size.height)) + UInt(monster.size.height) / 2)\n            \n            monster.position = CGPoint(x: xPos, y: yPos)\n            \n            // Add Sprite to Scene\n            self.addChild(monster)\n        }\n        \n    }\n    \n    override func update(currentTime: NSTimeInterval)  {\n        \n    }\n    \n}\n\n// Create a new instance of GameScene (created above)\nlet scene = GameScene(size: CGSize(width: 500, height: 500))\n\n// Create a view\nlet view = SKView(frame: NSRect(x: 0, y: 0, width: 500, height: 500))\n\n// Present the Scene using our view\nview.presentScene(scene)\n\n// Use this method to render the final scene\nXCPShowView(\"result\", view)\n"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/GameDevUniversity.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/SpriteKitTestbed.playground/Contents.swift",
    "content": "import Cocoa\nimport SpriteKit\nimport XCPlayground\n\n\n// Credit to http://ericasadun.com/2015/04/22/swift-simple-spritekit-experimentation/\n\n\n// Build scene and view\nlet sceneSize = CGSizeMake(400.0, 300.0)\nlet view = SKView(frame: CGRect(origin: CGPointZero, size: sceneSize))\nvar scene = SKScene(size: sceneSize)\nscene.backgroundColor = SKColor.lightGrayColor()\nXCPShowView(\"Scene\", view: view)\nview.presentScene(scene)\n\nvar shape1 = SKShapeNode(circleOfRadius: 20.0)\nshape1.fillColor = SKColor.redColor()\nscene.addChild(shape1)\nshape1.position = CGPointMake(200.0, 150.0)\n\nvar action = SKAction.repeatActionForever(SKAction.moveBy(CGVectorMake(0.02, 0.1), duration: 0.01))\nshape1.runAction(ac\n"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/SpriteKitTestbed.playground/Sources/SupportCode.swift",
    "content": "//\n// This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to SpriteKitTestbed.playground.\n//\n"
  },
  {
    "path": "Swift-Playgrounds/Specific Technologies/SpriteKit/SpriteKitTestbed.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx' auto-termination-delay='40' requires-full-environment='true'/>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Array.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Array.playground/section-1.swift",
    "content": "// Swift Standard Library - Types - Array\n// An Array is a generic type that manages an ordered collection of items, all of which must be of the same underlying type.\n\n// Creating and Array\nvar emptyArray = Array<Int>()\nvar equivilentEmptyArray = [Int]()\n\nlet numericArray = Array(count: 3, repeatedValue: 42)\nlet stringArray = Array(count: 2, repeatedValue: \"Hello\")\n\n\n// Accessing Array Elements\nvar subscriptableArray = [\"zero\", \"one\", \"two\", \"three\"]\nlet zero = subscriptableArray[0]\nlet three = subscriptableArray[3]\n\nsubscriptableArray[0] = \"nothing\"\nsubscriptableArray[3] = \"three items\"\nsubscriptableArray\n\n// It is not possible to insert additional items into the array using subscripting:\n// subscriptableArray[4] = \"new item\"\n// Fatal erro: Array Index out of range\n// Instead use append() or +=\n\n// You also can't modify the contents of an array that was initialised using let\nlet constantArray = [\"zero\", \"one\", \"two\", \"three\"]\n//constantArray[0] = \"nothing\"\n\nsubscriptableArray = [\"zero\", \"one\", \"two\", \"three\"]\nlet subRange = subscriptableArray[1...3]\n\nsubscriptableArray[1...2] = [\"oneone\", \"twotwo\"]\nsubscriptableArray\n\nsubscriptableArray[1...2] = []\nsubscriptableArray\n\n// It is not possible to insert additional items into the array using subscripting\n//subscriptableArray[4...5] = [\"four\", \"five\"]\n\n\n// Adding and Removing Elements\nvar array = [0, 1]\narray.append(2)\narray\narray.append(3)\narray\n// You can only append to an array that has been initialised with the var keyword.\n//constantArray.append(\"another\")\n\narray = [1, 2, 3]\narray.insert(0, atIndex: 0)\narray\n// The index must be less than or equal to the number of items in the collection\n//array.insert(6, atIndex: 6)\n// You can't insert into an array that was initialised with let\n\nlet removed = array.removeAtIndex(0)\narray\n// The index must be valid\n// You can't remove from an array that was created with let\n\nlet lastRemoved = array.removeLast()\narray\n// There must be at least one element in the array\n// You can't removeLast() from a constant array\n\narray = [0, 1, 2, 3]\narray.removeAll()\nlet count = array.count\narray\n// Unless you specify otherwise, the underlying backing storage will be cleared\narray = [0, 1, 2, 3]\narray.removeAll(keepCapacity: true)\narray\n\narray.reserveCapacity(10)\n// Ensures that the underlying storage can hold the given total number of elements\n\n\n// Querying an array\nvar arrayToCount = [\"zero\", \"one\", \"two\"]\nlet firstCount = arrayToCount.count\narrayToCount += [\"three\"]\nlet secondCount = arrayToCount.count\n\nlet firstIsEmpty = arrayToCount.isEmpty\narrayToCount.removeAll()\nlet secondIsEmpty = arrayToCount.isEmpty\n\nvar capacity = arrayToCount.capacity\narrayToCount.reserveCapacity(1000)\ncapacity = arrayToCount.capacity\n\n\n// Algorithms\n// Sort\n// The closure that you supply for isOrderedBefore should return a Boolean value to indicate whether one element should be before (true) or after (false) another element:\nvar arrayToSort = [3, 2, 5, 1, 4]\narrayToSort.sort { $0 < $1 }\narrayToSort\narrayToSort.sort { $1 < $0 }\narrayToSort\n// You can only sort an array inplace if it was declared with var\n\narrayToSort = [3, 2, 5, 1, 4]\nlet sortedArray = arrayToSort.sorted { $0 < $1 }\nsortedArray\nlet descendingArray = arrayToSort.sorted { $1 < $0 }\ndescendingArray\n\nsortedArray\nlet reversedArray = sortedArray.reverse()\nreversedArray\n\nlet filteredArray = sortedArray.filter { $0 % 2 == 0 }\nfilteredArray\n\nlet multipliedArray = sortedArray.map { $0 * 2 }\nmultipliedArray\n\nlet describedArray = sortedArray.map { \"Number: \\($0)\" }\ndescribedArray\n\nlet addResult = sortedArray.reduce(0) { $0 + $1 }\naddResult\nlet multipliedResult = sortedArray.reduce(0) { $0 * $1 }\nmultipliedResult\n\n\n// Operators\nvar operatorArray = [0, 1, 2]\noperatorArray += [3]\noperatorArray += [4, 5, 6]\n// The type of elements must match\n// You can only add new elements to an array that has been declared with var\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Array.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Dictionary.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Dictionary.playground/section-1.swift",
    "content": "// Swift Standard Library - Types - Dictionary\n\nvar emptyDictionary = Dictionary<String, Int>()\nvar equivilentEmptyDictionary = [String: Int]()\nvar anotherEmptyDictionary = Dictionary<String, Int>(minimumCapacity: 10)\nvar literalDictionary = [\"a\":1]\n\n\n// Accessing and Changing Dictionary Elements\nvar dictionary = [\"one\": 1, \"two\": 2, \"three\": 3]\nlet value = dictionary[\"two\"]\nif let unwrappedValue = dictionary[\"three\"] {\n    print(\"The integer value for \\\"three\\\" was: \\(unwrappedValue)\")\n    unwrappedValue\n}\n\ndictionary[\"three\"] = 33\ndictionary\n// You can add to a dictionary using subscripting\ndictionary[\"four\"] = 4\ndictionary\n// you can remove a value for a key by setting it to nil\ndictionary[\"three\"] = nil\ndictionary\n// You can't change, add or remove elements to a constant dictionary\n\ndictionary = [\"one\": 1, \"two\": 2, \"three\": 3]\nlet previousValue = dictionary.updateValue(22, forKey: \"two\")\ndictionary\nif let unwrappedPreviousValue = dictionary.updateValue(33, forKey: \"three\") {\n    print(\"Replaced the previous value: \\(unwrappedPreviousValue)\")\n} else {\n    print(\"Added a new value\")\n}\n\ndictionary = [\"one\": 1, \"two\": 2, \"three\": 3]\nlet prevValue = dictionary.removeValue(forKey: \"two\")\nif let unwrappedPreviousValue = dictionary.removeValue(forKey: \"three\") {\n    print(\"Removed the old value: \\(unwrappedPreviousValue)\")\n} else {\n    print(\"Didn't find a value for the given key to delete\")\n}\n\ndictionary.removeAll()\ndictionary\n\n\n// Querying a Dictionary\ndictionary = [\"one\": 1, \"two\": 2, \"three\": 3]\nlet elementCount = dictionary.count\n\nfor key in dictionary.keys {\n    print(\"Key: \\(key)\")\n}\nlet keysArray = Array(dictionary.keys)\n\nfor value in dictionary.values {\n    print(\"Value: \\(value)\")\n}\nlet valuesArray = Array(dictionary.values)\n\n\n// Operators\nlet dictionary1 = [\"one\": 1, \"two\": 2]\nvar dictionary2 = [\"one\": 1]\ndictionary2[\"two\"] = 2\nlet result = dictionary1 == dictionary2\n\ndictionary2 = [\"one\": 1]\nlet secondResult = dictionary1 != dictionary2\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/FreeFunctions.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/FreeFunctions.playground/section-1.swift",
    "content": "// Swift Standard Library - Free Functions\n\nprint(\"Hello, world!\\n\")\nprintln(\"Hello, world!\")\n\nvar array = [5, 1, 6, 4, 2, 3]\nsort(&array)\narray\n// You can't sort a constant array because sort mutates the array it operates on.\n\narray = [5, 1, 6, 4, 2, 3]\nvar result = sorted(array)\n\narray = [5, 1, 6, 4, 2, 3]\nsort(&array) { $0 > $1 }\narray\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/FreeFunctions.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/NumericTypes.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/NumericTypes.playground/section-1.swift",
    "content": "// Swift Standard Library - Types - Numeric Types\n\n// Boolean\nvar aBool: Bool\naBool = true\naBool = false\n!aBool\naBool.description\naBool.getMirror()\naBool.hashValue\n\n\n// Int\n// The primary integer type in Swift is Int, which is word-sized. This means that it holds 32 bits on 32-bit platforms, and 64 bits on 64-bit platforms.\n// For the majority of use cases, you should use the base Int type.\nvar anInt = Int()\nanInt.advancedBy(3)\nanInt.advancedBy(5) // I don't understand this one\nanInt\nanInt = -10\nanInt.distanceTo(20)\nanInt.encode()\nanInt.getMirror()\nanInt.predecessor()\nanInt.successor()\n\n// Int is 64 bit on my Mac OS X system\nInt.min\nInt.max\n\nUInt.min\nlet maxUInt = UInt.max\nprintln(\"Max UInt = \\(maxUInt)\")\n\nInt8.min\nInt8.max\nInt16.min\nInt16.max\nInt32.min\nInt32.max\nInt64.min\nInt64.max\n\nUInt8.min\nUInt8.max\nUInt16.min\nUInt16.max\nUInt32.min\nUInt32.max\nUInt64.min\nUInt64.max\n\n\n// Floating Point\n// The primary floating-point type in Swift is Double, which uses 64 bits. If you do not require 64-bit precision, Swift also includes a 32-bit Float type.\nvar aDouble = Double()\naDouble.advancedBy(5)\naDouble.description\naDouble.isFinite\naDouble.isInfinite\naDouble.isNaN\naDouble.isNormal\naDouble.isSignaling\naDouble.isSignMinus\naDouble.isSubnormal\naDouble.isZero\n\naDouble = 1.0 / 0.0\naDouble.isInfinite\naDouble.isNaN\n\naDouble = Double.NaN\naDouble.isNaN\n\naDouble = Double.abs(-7.3)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/NumericTypes.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Protocols.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Protocols.playground/section-1.swift",
    "content": "// Swift Standard Library - Protocols\n\n// Equatable\n// The Equatable protocol makes it possible to determine whether two values of the same type are considered to be equal.\nstruct MyEquatableStruct: Equatable {\n    var name = \"Untitled\"\n}\nfunc == (lhs: MyEquatableStruct, rhs: MyEquatableStruct) -> Bool {\n    return lhs.name == rhs.name\n}\n\nlet value1 = MyEquatableStruct()\nvar value2 = MyEquatableStruct()\nlet firstCheck = value1 == value2\nvalue2.name = \"A New Name\"\nlet secondCheck = value1 == value2\n\n\n// Comparable\n// The Comparable protocol makes it possible to compare two values of the same type\n// There is one required operator overload defined in the protocol (<) as well as one defined in the inherited Equatable protocol (==). You get >, <= and >= for free.\nstruct MyComparableStruct: Comparable {\n    var name = \"Untitled\"\n}\nfunc == (lhs: MyComparableStruct, rhs: MyComparableStruct) -> Bool {\n    return lhs.name == rhs.name\n}\nfunc < (lhs: MyComparableStruct, rhs: MyComparableStruct) -> Bool {\n    return lhs.name < rhs.name\n}\n\nlet value3 = MyComparableStruct()\nvar value4 = MyComparableStruct()\nlet thirdCheck = value3 < value4\nvalue4.name = \"A New Name\"\nlet fourthCheck = value4 < value3\nlet fifthCheck = value4 > value3\nlet sixthCheck = value4 <= value3\nlet seventhCheck = value4 >= value3\n\n\n// Printable\n// The Printable protocol allows you to customize the textual representation of any type ready for printing (for example, to Standard Out).\nstruct MyPrintableStruct: Printable {\n    var name = \"Untitled\"\n    var description: String {\n    return \"MyType: \\(name)\"\n    }\n}\n\nlet value = MyPrintableStruct()\nprintln(\"Created a \\(value)\") // Not working in Beta-3\n\n\n// Sequence Protocol\n// https://medium.com/swift-programming/sequence-beyond-primitive-iterations-in-swift-80bc2507d8cc\nclass TodoItem {\n    var name:String\n    var priority:Int\n    \n    init(name:String, priority:Int) {\n        self.name = name\n        self.priority = priority\n    }\n}\n\nstruct GenericGenerator<T>: GeneratorType {\n    var items:[T]\n    mutating func next() -> T? {\n        return items.isEmpty ? .None : items.removeAtIndex(0)\n    }\n}\n\nclass TodoItemRepository : SequenceType {\n    var items:[TodoItem] = [];\n    func addItem(item:TodoItem) {\n        items += [item]\n    }\n    func generate() -> GenericGenerator<TodoItem> {\n        return GenericGenerator(items: items)\n    }\n}\n\nvar repo = TodoItemRepository()\nrepo.addItem(TodoItem(name: \"One\", priority: 5))\nrepo.addItem(TodoItem(name: \"Two\", priority: 2))\nrepo.addItem(TodoItem(name: \"Three\", priority: 6))\nrepo.addItem(TodoItem(name: \"Four\", priority: 0))\n\nrepo.items.count\nfor item in repo {\n    println(\"\\(item.name) has a priority of \\(item.priority)\")\n}\nrepo.items.count\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Protocols.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/String.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/String.playground/section-1.swift",
    "content": "// Swift Standard Library - Types - String\n// A String represents an ordered collection of characters.\n\n\n// Creating a String\nlet emptyString = String()\nlet equivilentString = \"\"\n\nlet repeatedString = String(count: 5, repeatedValue: Character(\"a\"))\n\n\n// Querying a String\nvar string = \"Hello, world!\"\nlet firstCheck = string.isEmpty\nstring = \"\"\nlet secondCheck = string.isEmpty\n\nstring = \"Hello, world!\"\nlet hasPrefixFirstCheck = string.hasPrefix(\"Hello\")\nlet hasPrefixSecondCheck = string.hasPrefix(\"hello\")\n\nlet hasSuffixFirstCheck = string.hasSuffix(\"world!\")\nlet hasSuffixSecondCheck = string.hasSuffix(\"World!\")\n\n\n// Changing and Converting Strings\nstring = \"42\"\nif let number = Int(string) {\n    print(\"Got the number: \\(number)\")\n} else {\n    print(\"Couldn't convert to a number\")\n}\n\n\n// Operators\n// Concatinate +\nlet combination = \"Hello \" + \"world\"\n// You can use the + operator with two strings as shown in the combination example, or with a string and a character in either order:\nlet exclamationPoint: Character = \"!\"\nvar charCombo = combination\ncharCombo.append(exclamationPoint)\n//var extremeCombo: String = exclamationPoint\n//extremeCombo.append(charCombo)\n\n// Append +=\nstring = \"Hello \"\nstring += \"world\"\nstring.append(exclamationPoint)\nstring\n\n// Equality ==\nlet string1 = \"Hello world!\"\nlet string2 = \"Hello\" + \" \" + \"world\" + \"!\"\nlet equality = string1 == string2\n\n// Less than <\nlet stringGreater = \"Number 3\"\nlet stringLesser = \"Number 2\"\nlet resulNotLessThan = stringGreater < stringLesser\nlet resultIsLessThan = stringLesser < stringGreater\n\n\n\n// What is missing from this chapter?\n// - How does the less than operator work?\n\"abc\" < \"def\"\n\"def\" < \"abc\"\n\"Number 2\" < \"number 1\"\n// It just looks at the ordinal valu of the first character???\n\n// - Does the greater than symbol work?\n\"abc\" > \"def\"\n\"def\" > \"abc\"\n\"Number 2\" > \"number 1\"\n\n// - How do you access the rodinal values of Characters?\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/String.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Undocumented.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Undocumented.playground/section-1.swift",
    "content": "// http://practicalswift.com/2014/06/14/the-swift-standard-library-list-of-built-in-functions/\n\nimport Cocoa\n\n\nabs(-1)\nabs(42)\n\nvar languages = [\"Swift\", \"Objective-C\"]\ncontains(languages, \"Swift\")\ncontains(languages, \"Java\")\ncontains([29, 85, 42, 96, 75], 42)\n\nvar oldLanguagees = dropFirst(languages)\nlanguages\n\nlanguages = [\"Swift\", \"Objective-C\"]\nvar newLanguages = dropLast(languages)\nlanguages\n\nlanguages = [\"Swift\", \"Objective-C\"]\ndump(languages)\n\nequal(languages, [\"Swift\", \"Objective-C\"])\n\nfor i in filter(1...100, { $0 % 10 == 0 }) {\n    println(i)\n}\n\nfind(languages, \"Swift\")\n\nindices([29, 85, 42])\n\njoin(\":\", [\"A\", \"B\", \"C\"])\n\nmap(1...3, { $0 * 5 })\nfor i in map(1...10, { $0 * 10 }) {\n    println(i)\n    assert(contains([10, 20, 30, 40, 50, 60, 70, 80, 90, 100],i))\n}\n\nmax(1, 3, 8, 2)\n\nmaxElement(1...10)\nmaxElement(languages)\n\nminElement(1...10)\nminElement(languages)\n\nlet reducedLanguages = reduce(languages, \"\", { $0 + $1 })\nreducedLanguages\nlet reducedArray = reduce([10, 20, 5], 1, { $0 * $1 })\nreducedArray\n\nreverse([1,2,3])\n\nstartsWith(\"foobar\", \"foo\")\nstartsWith(10..<100, 10..<15)\nstartsWith(languages, [\"Swift\"])\n\n\n/*\nabs(...)\nadvance(...)\nalignof(...)\nalignofValue(...)\nassert(...)\nbridgeFromObjectiveC(...)\nbridgeFromObjectiveCUnconditional(...)\nbridgeToObjectiveC(...)\nbridgeToObjectiveCUnconditional(...)\nc_malloc_size(...)\nc_memcpy(...)\nc_putchar(...)\ncontains(...)\ncount(...)\ncountElements(...)\ncountLeadingZeros(...)\ndebugPrint(...)\ndebugPrintln(...)\ndistance(...)\ndropFirst(...)\ndropLast(...)\ndump(...)\nencodeBitsAsWords(...)\nenumerate(...)\nequal(...)\nfilter(...)\nfind(...)\ngetBridgedObjectiveCType(...)\ngetVaList(...)\nindices(...)\ninsertionSort(...)\nisBridgedToObjectiveC(...)\nisBridgedVerbatimToObjectiveC(...)\nisUniquelyReferenced(...)\njoin(...)\nlexicographicalCompare(...)\nmap(...)\nmax(...)\nmaxElement(...)\nmin(...)\nminElement(...)\nnumericCast(...)\npartition(...)\nposix_read(...)\nposix_write(...)\nprint(...)\nprintln(...)\nquickSort(...)\nreduce(...)\nreflect(...)\nreinterpretCast(...)\nreverse(...)\nroundUpToAlignment(...)\nsizeof(...)\nsizeofValue(...)\nsort(...)\nsplit(...)\nstartsWith(...)\nstrideof(...)\nstrideofValue(...)\nswap(...)\nswift_MagicMirrorData_summaryImpl(...)\nswift_bufferAllocate(...)\nswift_keepAlive(...)\ntoString(...)\ntranscode(...)\nunderestimateCount(...)\nunsafeReflect(...)\nwithExtendedLifetime(...)\nwithObjectAtPlusZero(...)\nwithUnsafePointer(...)\nwithUnsafePointerToObject(...)\nwithUnsafePointers(...)\nwithVaList(...)\n\n*/\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Swift Stanard Library/Undocumented.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/ASwiftTour.playground/Contents.swift",
    "content": "// Playground - noun: a place where people can play\n\nimport Cocoa\n\nvar str = \"Hello, world!\"\n\n\n// Simple Values\nvar myVariable = 42\nmyVariable = 50\nlet myConstant = 42\n\nlet implicitInteger = 70\nlet implicitDouble = 70.0\nlet explicitDouble: Double = 70\n// Experiment - Create a constant with an explicit type of Float and a value of 4.\nlet explicitFloat: Float = 4\n\n// Values are never implicitly converted to another type.\nlet label = \"The width is \"\nlet width = 94\nlet widthLabel = label + String(width)\n// Experiment - Try removing the conversion to String from the last line. What error do you get?\n// let widthLabel2 = label + width // Binary operation '+' cannot be applied to operands of type 'String and 'Int'\n\nlet apples = 3\nlet oranges = 5\nlet appleSummary = \"I have \\(apples) apples\"\nlet fruitSummary = \"I have \\(apples + oranges) pieces of fruit\"\n// Experiment - Use \\() to include a floating-point calculation in a string and to include someone’s name in a greeting.\nlet π: Float = 3.14\nlet name = \"Peter Pie\"\nlet piePy = \"\\(name) likes the number \\(π)\"\n\nlet quotation = \"\"\"\nI said \"I have \\(apples) apples.\"\nAnd then I said \"I have \\(apples + oranges) pieces of fruit.\"\n\"\"\"\n\n// Arrays and Dictionaries\nvar shoppingList = [\"catfish\", \"water\", \"tulips\"]\nshoppingList[1] = \"bottle of water\"\nshoppingList\n\nvar occupations = [\n    \"Malcom\": \"Captain\",\n    \"Kaylee\": \"Mechanic\",\n    ]\noccupations[\"Jayne\"] = \"Public Relations\"\noccupations\n\n// Arrays automatically grow as you add elements\nshoppingList.append(\"Blue paint\")\nprint(shoppingList)\n\n// Initialising an empty array or dict\nlet emptyArray: [String] = []\nvar emptyDictionary: [String: Float] = [:]\n\nshoppingList = []\noccupations = [:]\n\n\n// Control Flow\nlet individualScores = [75, 43, 103, 87, 12]\nvar teamScore = 0\nfor score in individualScores {\n    if score > 50 {\n        teamScore += 3\n    } else {\n        teamScore += 1\n    }\n}\nteamScore\n\n\n// Optionals\n// Normal values cannot be nil. They must have a valid value. Sometimes you may not have\n// a valid value. In this case you can use an optional type. They are values that can either\n// hold a valid value or nil.\nvar optionalString: String? = \"Hello\"\noptionalString == nil\n\nvar optionalName: String? = \"John Appleseed\"\n//optionalName = nil\nvar greeting = \"Hello!\"\nif let name = optionalName {\n    greeting += \", \\(name)\"\n} else {\n    greeting\n}\n\nlet nickName: String? = nil\nlet fullName: String = \"John Appleseed\"\nlet informalGreeting: String = \"Hi \\(nickName ?? fullName)\"\n\n\n// Switches\nlet vegetable = \"red pepper\"\nswitch vegetable {\ncase \"celery\":\n    print(\"Add some raisins and make ants on a log.\")\ncase \"cucumber\", \"watercress\":\n    print(\"That would make a good tea sandwich.\")\ncase let x where x.hasSuffix(\"pepper\"):\n    print(\"Is it a spicy \\(x)?\")\ndefault:\n    print(\"Everything tastes good in soup.\")\n}\n// if default: is removed we get the error \"Switch must be exhaustive\". This means that every\n// possible option must be included in the switch/case statement so that the result cannot be \n// undefined.\n\n\n// for-in loop (Also tuples)\nlet interestingNumbers = [\n    \"Prime\": [2,3,5,7,11,13],\n\"Fibonacci\": [1,1,2,3,5,8],\n   \"Square\": [1,4,9,16,25],\n]\nvar largest = 0\nvar largestKind = \"\"\nfor (kind, numbers) in interestingNumbers {\n    for number in numbers {\n        if number > largest {\n            largest = number\n            largestKind = kind\n        }\n    }\n}\nlargest\nlargestKind\n\n\n// while and do-while loops\nvar n = 2\nwhile n < 100 {\n    n = n * 2\n}\nn\n\nvar m = 2\nrepeat {\n    m = m * 2\n} while m < 100\nm\n\n// Indexes in loops and the Range operators\nvar total = 0\nfor i in 0..<4 {\n    total += i\n}\ntotal\n\n\n\n// Functions and Closures\nfunc greet(person: String, day: String) -> String {\n    return \"Hello \\(person), today is \\(day).\"\n}\ngreet(person: \"Bob\", day: \"Tuesday\")\n\n//Experiment - Remove the day parameter. Add a parameter to include today’s lunch special in the greeting.\nfunc greet(person: String, special: String) -> String {\n    return \"Hello \\(person), todays lunch special is: \\(special)\"\n}\ngreet(person: \"Bob\", special:\"Chicken Parmigiana\")\n\nfunc greet(_ person: String, on day: String) -> String {\n    return \"Hello \\(person), today is \\(day).\"\n}\ngreet(\"John\", on: \"Wednesday\")\n\n\n// Use a tuple to make a compound value - for example, to return multiple values from a function. The elements of a tuple can be referred to either by name or by number\nfunc calculateStatistics(scores: [Int]) -> (min: Int, max: Int, sum: Int) {\n    var min = scores[0]\n    var max = scores[0]\n    var sum = 0\n    \n    for score in scores {\n        if score > max {\n            max = score\n        } else if score < min {\n            min = score\n        }\n        sum += score\n    }\n    return (min, max, sum)\n}\nlet statistics = calculateStatistics(scores: [5, 3, 100, 3, 9])\nstatistics.sum\nstatistics.2\n\n// Functions can be nested\nfunc returnFifteen() -> Int {\n    var y = 10\n    func add() {\n        y = y + 5\n    }\n    add()\n    return y\n}\nreturnFifteen()\n\n//  Functions are a first-class type. This means that a function can return another function as its value.\nfunc makeIncrementer() -> ((Int) -> Int) {\n    func addOne(number: Int) -> Int {\n        return 1 + number\n    }\n    return addOne\n}\nvar increment = makeIncrementer()\nincrement(7)\n\n// A function can take another function as one of its arguments.\nfunc hasAnyMatches(list: [Int], condition: (Int) -> Bool) -> Bool {\n    for item in list {\n        if condition(item) {\n            return true\n        }\n    }\n    return false\n}\nfunc lessThanTen(number: Int) -> Bool {\n    return number < 10\n}\nvar numbers = [20, 19, 7, 12]\nhasAnyMatches(list: numbers, condition: lessThanTen)\n\n// Closures\n// Use the keyword \"in\" to seperate the parameters from the body\nnumbers.map({ (number: Int) -> Int in\n    let result = 3 * number\n    return result\n})\n// Experiment - Rewrite the closure to return zero for all odd numbers.\nnumbers.map({ (number:Int) -> Int in\n    if number % 2 == 1 {\n        return 0\n    }\n    return number\n})\n\n// Single statement closures implicitly return the value of their only statement\nlet mappedNumbers = numbers.map({ number in 3 * number})\nmappedNumbers\n\n// A closure passed as the last argument to a function can appear immediately after the parentheses\nlet sortedNumbers = numbers.sorted { $0 > $1 }\nsortedNumbers\n\n\n// Objects and Classes\nclass Shape {\n    var numberOfSides = 0\n    func simpleDescription() -> String {\n        return \"A shape with \\(numberOfSides) sides.\"\n    }\n}\n\nvar shape = Shape()\nshape.numberOfSides = 7\nvar shapeDescription = shape.simpleDescription()\n\n//Experiment - Add a constant property with let, and add another method that takes an argument.\nextension Shape {\n    //let solid = true\n    func blah(a: Int) -> Int {\n        return a * numberOfSides\n    }\n}\n\n\nclass NamedShape {\n    var numberOfSides: Int = 0\n    var name: String\n    \n    init(name: String) {\n        self.name = name\n    }\n    \n    func simpleDescription() -> String {\n        return \"A shape with \\(numberOfSides) sides.\"\n    }\n}\n// Every property needs a value assigned - either in its declaration (as with numberOfSides) or in the initialiser (as with name). Note the use of self to differentiate between the name property and the name argument.\n\nclass Square: NamedShape {\n    var sideLength: Double\n    \n    init(sideLength: Double, name: String) {\n        self.sideLength = sideLength\n        super.init(name: name)\n        numberOfSides = 4\n    }\n    \n    func area() -> Double {\n        return sideLength * sideLength\n    }\n    \n    override func simpleDescription() -> String {\n        return \"A square with sides of length \\(sideLength).\"\n    }\n}\nlet test = Square(sideLength:5.2, name:\"My test square\")\ntest.area()\ntest.simpleDescription()\n\n// Experiment - Make another subclass of NamedShape called Circle that takes a radius and a name as arguments to its initializer. Implement an area() and a simpleDescription() method on the Circle class.\nclass Circle: NamedShape {\n    var radius: Double\n    \n    init(radius: Double, name: String) {\n        self.radius = radius\n        super.init(name: name)\n        numberOfSides = 1\n    }\n    \n    func area() -> Double {\n        return 3.14 * radius * radius\n    }\n    \n    override func simpleDescription() -> String {\n        return \"A circle with radius \\(radius)\"\n    }\n}\nlet testCircle = Circle(radius:2.4, name:\"my test circle\")\ntestCircle.area()\ntestCircle.simpleDescription()\n\nclass EquilateralTriangle: NamedShape {\n    var sideLength: Double = 0.0\n    \n    init(sideLength: Double, name: String) {\n        self.sideLength = sideLength\n        super.init(name:name)\n        numberOfSides = 3\n    }\n    \n    var perimeter: Double {\n        get {\n            return 3.0 * sideLength\n        }\n        set (newPerimeter){\n            sideLength = newPerimeter / 3.0\n        }\n    }\n    \n    override func simpleDescription() -> String {\n        return \"An equilateral tringle with sides of length \\(sideLength).\"\n    }\n}\nvar triangle = EquilateralTriangle(sideLength:3.1, name:\"my test triangle\")\ntriangle.perimeter\ntriangle.perimeter = 9.9\ntriangle.sideLength\n\n\nclass TriangleAndSquare {\n    var triangle:EquilateralTriangle {\n        willSet {\n            square.sideLength = newValue.sideLength\n        }\n    }\n    \n    var square: Square {\n        willSet {\n            triangle.sideLength = newValue.sideLength\n        }\n    }\n    \n    init(size: Double, name: String) {\n        square = Square(sideLength: size, name: name)\n        triangle = EquilateralTriangle(sideLength: size, name:name)\n    }\n}\nvar triangleAndSquare = TriangleAndSquare(size:10, name:\"another test shape\")\ntriangleAndSquare.square.sideLength\ntriangleAndSquare.triangle.sideLength\ntriangleAndSquare.square = Square(sideLength:50, name:\"larger square\")\ntriangleAndSquare.triangle.sideLength\n\n\n// Optionals\n// For methods, properties and subscripts you can write a ? afterwards and everything after the question mark will be ignored if the object is nil.\nvar optionalSquare: Square? = Square(sideLength: 2.5, name:\"optional square\")\nvar sideLength = optionalSquare?.sideLength\n// let sideLength2 = optionalSquare.sideLength Doesn't work because optionalSquare has a type of Square? not Square. This is what the unwrapping is refering to.\noptionalSquare = nil\nsideLength = optionalSquare?.sideLength\n\n\n// Enumerations and Structures\nenum Rank: Int {\n    case ace = 1\n    case two, three, four, five, six, seven, eight, nine, ten\n    case jack, queen, king\n    func simpleDescription() -> String {\n        switch self {\n        case .ace:\n            return \"ace\"\n        case .jack:\n            return \"jack\"\n        case .queen:\n            return \"queen\"\n        case .king:\n            return \"king\"\n        default:\n            return String(self.rawValue)\n        }\n    }\n}\nlet ace = Rank.ace\nlet aceRawValue = ace.rawValue\nace.simpleDescription()\nlet two = Rank.two\ntwo.simpleDescription()\ntwo.rawValue\n\n// Experiment - Write a function that compares two Rank values by comparing their raw values.\nfunc compare(rank: Rank, toRank: Rank) -> Bool {\n    return rank.rawValue == toRank.rawValue\n}\ncompare(rank: ace, toRank: two)\ncompare(rank: ace, toRank: ace)\n\nif let convertedRank = Rank(rawValue: 3) {\n    let _ = convertedRank.simpleDescription()\n}\n\n// enums don't need to be backed by a raw value if they don't make sense. You can also use Int, Double or String as the raw backing type\nenum Suit {\n    case spades, hearts, diamonds, clubs\n    \n    func simpleDescription() -> String {\n        switch self {\n        case .spades:\n            return \"spades\"\n        case .hearts:\n            return \"hearts\"\n        case .diamonds:\n            return \"diamonds\"\n        case .clubs:\n            return \"clubs\"\n        }\n    }\n}\n\nextension Suit {\n    func color() -> String {\n        switch self {\n        case .spades, .clubs:\n            return \"black\"\n        case .hearts, .diamonds:\n            return \"red\"\n        }\n    }\n}\n\nlet hearts = Suit.hearts\nlet heartsDescription = hearts.simpleDescription()\n// hearts.toRaw() // This is an error because Suit doesnt have a raw backing type.\nlet heartsColor = hearts.color()\n\n// Enumerations\nenum ServerResponse {\n    case Result(String, String)\n    case Error(String)\n}\n\nlet success = ServerResponse.Result(\"6:00am\", \"8.09pm\")\nlet failure = ServerResponse.Error(\"Out of cheese\")\n\nswitch failure {\ncase let .Result(sunrise, sunset):\n    let _ = \"Sunrise is at \\(sunrise) and sunset is at \\(sunset)\"\ncase let .Error(error):\n    let _ = \"Failure... \\(error)\"\n}\n// Experiment - Add a third case to ServerResponse and to the switch\n\n// Structures\n// Structures are very similar to classes. They can both have methods and initialisers. One key difference is that structures are always copied when they are passed around in code. Classes are passed by reference.\nstruct Card {\n    var rank: Rank\n    var suit: Suit\n    \n    func simpleDescription() -> String {\n        return \"The \\(rank.simpleDescription()) of \\(suit.simpleDescription())\"\n    }\n}\n\n// Experiment - Add a method to Card that creates a full deck of cards, with one card of each combination of rank and suit\nextension Card {\n    func createFullDeck() -> [Card] {\n        var deck: [Card] = []\n        \n        func appendFullRank(suit: Suit) {\n            for rawRank in 1...13 {\n                let card = Card(rank:Rank(rawValue:rawRank)!, suit:suit)\n                deck.append(card)\n            }\n        }\n        \n        for suit in [Suit.hearts, Suit.diamonds, Suit.spades, Suit.clubs] {\n            appendFullRank(suit: suit)\n        }\n        \n        return deck\n    }\n}\nlet threeOfSpades = Card(rank: .three, suit:.spades)\nlet threeOfSpadesDescription = threeOfSpades.simpleDescription()\n\nlet aFullDeck = threeOfSpades.createFullDeck()\naFullDeck.map({ card in card.simpleDescription() })\n\n\n// Protocols and Extensions\nprotocol ExampleProtocol {\n    var simpleDescription: String { get }\n    mutating func adjust()\n}\n\nclass SimpleClass: ExampleProtocol {\n    var simpleDescription: String = \"A very simple class.\"\n    var anotherProperty: Int = 69105\n    func adjust() {\n        simpleDescription += \" Now 100% adjusted.\"\n    }\n}\nvar a = SimpleClass()\na.adjust()\nlet aDescription = a.simpleDescription\n\nstruct SimpleStructure: ExampleProtocol {\n    var simpleDescription: String = \"A simple structure\"\n    mutating func adjust() {\n        simpleDescription += \" (adjusted)\"\n    }\n}\nvar b = SimpleStructure()\nb.adjust()\nlet bDescription = b.simpleDescription\n\n\n\n// Experiment - Write an enumeration that conforms to this protocol\nenum SimpleEnum: Int, ExampleProtocol {\n    case A = 1, B, C, D, E\n    \n    var simpleDescription: String {\n    get {\n        return \"A simple enum \\(self.rawValue)\"\n    }\n    }\n    mutating func adjust() {\n        self = SimpleEnum(rawValue:(self.rawValue + 1))!\n    }\n}\nvar c = SimpleEnum.A\nc.adjust()\nlet cDescription = c.simpleDescription\n\n\n// Extensions\nextension Int: ExampleProtocol {\n    var simpleDescription: String {\n        return \"The number \\(self)\"\n    }\n    \n    mutating func adjust() {\n        self += 42\n    }\n}\n7.simpleDescription\n// The 7 above is a literal constant not a variable. Therefore you can't mutate it with adjust.\n\nvar someInt = 4\nsomeInt.adjust()\nsomeInt\n\n// Experiment - Write an extension for the Double type that adds an absoluteValue property.\nextension Double {\n    var absoluteValue: Double {\n        return self > 0 ? self : -self\n    }\n}\n\nvar aDouble = -7.0\naDouble.absoluteValue\n\n4.absoluteValue\n(-6.0).absoluteValue\nlet neg = -6.0\nneg.absoluteValue\nlet absNeg = (-6.0.absoluteValue)\n\n\nlet protocolValue: ExampleProtocol = a\nprotocolValue.simpleDescription\n// protocolValue.anotherProperty // Uncomment to see the error\n\n\n// Error Handling\n// You represent errors using any type that adopts the Error protocol\nenum PrinterError: Error {\n    case outOfPaper\n    case noToner\n    case onFire\n}\n\nfunc send(job: Int, toPrinter printerName: String) throws -> String {\n    if printerName == \"Never Has Toner\" {\n        throw PrinterError.noToner\n    }\n    return \"Job sent\"\n}\n\ndo {\n    let printerResponse = try send(job: 1040, toPrinter: \"Bi Sheng\")\n    printerResponse\n} catch {\n    error\n}\n\n// Experiment\ndo {\n    let printerResponse2 = try send(job: 1040, toPrinter: \"Never Has Toner\")\n    printerResponse2\n} catch {\n    error\n}\n\n// You can provide multiple catch blocks to handle specific errors\ndo {\n    let printerResponse = try send(job: 1440, toPrinter: \"Gutenberg\")\n    printerResponse\n} catch PrinterError.onFire {\n    print(\"I'll just put this over here, with the rest of the fire\")\n} catch let printerError as PrinterError {\n    print(\"Printer error: \\(printerError).\")\n} catch {\n    print(error)\n}\n\n// Experiment\n\n\nlet printerSuccess = try? send(job: 1884, toPrinter: \"Mergenthaler\")\nlet printerFailure = try? send(job: 1885, toPrinter: \"Never Has Toner\")\n\n// Defer\nvar fridgeIsOpen: Bool = false\nlet fridgeContent = [\"milk\", \"eggs\", \"leftovers\"]\n\nfunc fridgeContains(_ food: String) -> Bool {\n    fridgeIsOpen = true\n    defer {\n        fridgeIsOpen = false\n    }\n    \n    let result = fridgeContent.contains(food)\n    return result\n}\nfridgeContains(\"banana\")\nfridgeIsOpen\n\n\n// Generics\nfunc makeArray<Item>(repeating item: Item, numberOfTimes: Int) -> [Item] {\n    var result = [Item]()\n    for _ in 0..<numberOfTimes {\n        result.append(item)\n    }\n    return result\n}\nmakeArray(repeating: \"knock\", numberOfTimes: 4)\n\n// Reimplement the Swift standard library's optional type\nenum OptionalValue<Wrapped> {\n    case none\n    case some(Wrapped)\n}\n\nvar possibleInteger: OptionalValue<Int> = .none\npossibleInteger = .some(100)\n\nfunc anyCommonElements <T: Sequence, U: Sequence>(_ lhs: T, _ rhs: U) -> Bool\n    where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element {\n    for lhsItem in lhs {\n        for rhsItem in rhs {\n            if lhsItem == rhsItem {\n                return true\n            }\n        }\n    }\n    return false\n}\nanyCommonElements([1,2,3], [3])\nanyCommonElements([1,2,3], [6])\nanyCommonElements([1,2,3], [3.0])\n\n// Experiment - Modify the anyCommonElements(_:_:) function to make a function that returns an array of the elements that any two sequences have in common.\nfunc returnAnyCommonElements <T: Sequence, U: Sequence>(_ lhs: T, _ rhs: U) -> [T.Iterator.Element]\n    where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element {\n    var commonElements: [T.Iterator.Element] = []\n    for lhsItem in lhs {\n        for rhsItem in rhs {\n            if lhsItem == rhsItem {\n                commonElements.append(lhsItem)\n            }\n        }\n    }\n    return commonElements\n}\nreturnAnyCommonElements([1, 2, 3], [2, 3, 4])\n//returnAnyCommon\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/ASwiftTour.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx' executeOnSourceChanges='true'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/ASwiftTour.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n      <LoggerValueHistoryTimelineItem\n         documentLocation = \"file:///Users/danielpi/repos/Swift-Playgrounds/Swift-Playgrounds/The%20Swift%20Programming%20Language/ASwiftTour.playground#CharacterRangeLen=0&amp;CharacterRangeLoc=3510&amp;EndingColumnNumber=0&amp;EndingLineNumber=142&amp;StartingColumnNumber=0&amp;StartingLineNumber=142&amp;Timestamp=645595022.027087\"\n         selectedRepresentationIndex = \"0\"\n         shouldTrackSuperviewWidth = \"NO\">\n      </LoggerValueHistoryTimelineItem>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/01-TheBasics.playground/Contents.swift",
    "content": "// The Basics Chapter of “The Swift Programming Language.” iBooks. https://itun.es/au/jEUH0.l\n\n//: # The Basics\n//: ## Constants and Variables\n//: ### Declaring Constants and Variables\n\nlet maximumNumberOfLoginAttempts = 10\nvar currentLoginAttempt = 0\n\nvar x = 0.0, y = 0.0, z = 0.0\n\n//: ### Type Annotations\nvar welcomeMessage: String\nwelcomeMessage = \"Hello\"\n\nvar red, green, blue: Double\n\n//: ### Naming Constants and Variables\nlet π = 3.14159\nlet 你好 = \"你好世界\"\nlet 🐶🐮 = \"dogcow\"\n\nvar friendlyWelcome = \"Hello!\"\nfriendlyWelcome = \"Bonjour!\"\n\nlet languageName = \"Swift\"\n//languageName = \"Swift++\" // Compile time error\n\n//: Printing Constants and Variables\nprint(friendlyWelcome)\n\nprint(π, 你好, 🐶🐮, separator: \", \", terminator: \"\")\n\nprint(\"The current value of friendlyWelcome is \\(friendlyWelcome)\")\n\n//: ## Comments\n// this is a comment\n\n/* this is also a comment,\nbut written over multiple lines*/\n\n/* this is the start of the first multiline comment\n/* this is the second, nested multiline comment */\nthis is the end of the first multiline comment */\n\n//: ## Semicolons\nlet cat = \"🐱\"; print(cat)\n\n//: ## Integers\n//: ### Integer Bounds\nlet minValue = UInt8.min\nlet maxValue = UInt8.max\n\n//: ## Floating-Point Numbers\nvar w = [1, 1.2]\n\n\n//: ## Type Safety and Type Inference\nvar meaningOfLife = 42\n// inferred to be of type Int\n// meaningOfLife = 35.0 //Type Error\n\nlet  pi = 3.14159\nlet anotherPi = 3 + 0.14159\n\n\n//: ## Numeric Literals\nlet descimalInteger = 17\nlet binaryInteger = 0b10001\nlet octalInteger = 0o21\nlet hexadecimalInteger = 0x11\n\n//let hexFloat = 0x1234.0x5678\n\n1.25e2\n1.25e-2\n\n0xFp2\n0x8p4\n\nlet decimalDouble = 12.1875\nlet exponentDouble = 1.21875e1\nlet hexadecialDouble = 0xC.3p0\n\nlet paddedDouble = 000123.456\nlet oneMillion = 1_000_000\nlet justOverOneMillion = 1_000_000.000_000_1\n\n//: ## Numeric Conversion\n//: ### Integer Conversion\n//let cannotBeNegative: UInt8 = -1\n//let tooBig: Int8 = Int8.max + 1\nlet twoThousand: UInt16 = 2_000\nlet one: UInt8 = 1\nlet twoThousandAndOne = twoThousand + UInt16(one)\n\n//: ### Integer and Floating Point Conversion\nlet three = 3\nlet pointOneFourOneFiveNine = 0.14159\nlet pi2 = Double(three) + pointOneFourOneFiveNine\n\nlet integerPi = Int(pi)\n// Floats are always truncated when cast to Integers\nlet integerFourPointSeven = Int(4.75)\nlet integerNegativeThreePointNine = Int(-3.9)\n// Literals can be cross type combined because they have no type until they are evaluated\n3 + 0.14159\n\n\n//: ## Type Aliases\n// Type aliases are useful when you want to refer to an existing type by a name that is contextually more appropriate, such as when working with data of a specific size from an external source:\n\ntypealias AudioSample = UInt16\nvar macAmplitudeFound = AudioSample.min\n\n\n//: ## Booleans\nlet orangesAreOrange = true\nlet turnipsAreDelicious = false\n\nif turnipsAreDelicious {\n    print(\"Mmm, tasty turnips!\")\n} else {\n    print(\"Eww, turnips are horrible.\")\n}\n\n// Non-Bool types can't be used for flow control\nlet i = 1\n/*\nif i {\n    \n}\n*/\nif i == 1 {\n    \n}\n\n\n//: ## Tuples\nlet http404Error = (404, \"Not Found\")\n\nlet (statusCode, statusMessage) = http404Error\nprint(\"The status code is \\(statusCode)\")\nprint(\"The status message is \\(statusMessage)\")\n\n// use _ if you don't want to decompose one of the values of a tuple\nlet (justTheStatusCode, _) = http404Error\nprint(\"The status code is \\(justTheStatusCode)\")\n\n// You can access the values of the tuple using index numbers\nprint(\"The status code is \\(http404Error.0)\")\nprint(\"The status message is \\(http404Error.1)\")\n\n// You can name the elements of a tuple when it is defined\nlet http200Status = (statusCode: 200, description: \"OK\")\nprint(\"The status code is \\(http200Status.statusCode)\")\nprint(\"The status message is \\(http200Status.description)\")\n// “Tuples are useful for temporary groups of related values. They are not suited to the creation of complex data structures. If your data structure is likely to persist beyond a temporary scope, model it as a class or structure, rather than as a tuple. For more information”\n\n\n//: ## Optionals\nlet possibleNumber = \"123\"\nlet convertedNumber = Int(possibleNumber)\n// convertedNumber is inferred to be ot type \"Int?\" (optional Int)\n\n// nil\nvar serverResponseCode: Int? = 404\nserverResponseCode = nil\n\nvar surveyAnswer: String?\n// surveyAnswer is automatically set to nil\n\n// If statements and forced Unwrapping\nif convertedNumber != nil {\n    print(\"convertedNumber contains some integer value.\")\n}\n\nif convertedNumber != nil {\n    print(\"convertedNumber has an integer value of \\(convertedNumber!)\")\n}\n\n\n//: ### Optional Binding\n\nif let actualNumber = Int(possibleNumber) {\n    print(\"\\'\\(possibleNumber)\\' has a value of \\(actualNumber)\")\n} else {\n    print(\"\\'\\(possibleNumber)\\' could not be converted to an Int\")\n}\n\nif let firstNumber = Int(\"4\"), let secondNumber = Int(\"42\"), firstNumber < secondNumber && secondNumber < 100 {\n    print(\"\\(firstNumber) < \\(secondNumber) < 100\")\n}\n\nif let firstNumber = Int(\"4\") {\n    if let secondNumber = Int(\"42\") {\n        if firstNumber < secondNumber && secondNumber < 100 {\n            print(\"\\(firstNumber) < \\(secondNumber) < 100\")\n        }\n    }\n}\n\n\n//: ### Implicitly Unwrapped Optionals\n//: Implicitly unwrapped optionals are useful when an optional’s value is confirmed to exist immediately after the optional is first defined and can definitely be assumed to exist at every point thereafter. The primary use of implicitly unwrapped optionals in Swift is during class initialization\n\nlet possibleString: String? = \"An optional string.\"\nlet forcedString: String = possibleString!\n\nlet assumedString: String! = \"An implicitly unwrapped optional string\"\nlet implicitString: String = assumedString\n\nif assumedString != nil {\n    print(assumedString)\n}\n\nif let definiteString = assumedString {\n    print(definiteString)\n}\n//:  Implicitly unwrapped optionals should not be used when there is a possibility of a variable becoming nil at a later point. Always use a normal optional type if you need to check for a nil value during the lifetime of a variable.\n\n//: ## Error Handling\n//: In contrast to optionals, which can use the presence or absence of a value to signify success or failure of a function, error handling allows you to determine the underlying cause of failure and if necessary propagate the error to another part of your program. \n\nfunc canThrowError() throws {\n    // This function may or may not throw an error.\n}\n\ndo {\n    try canThrowError()\n    // no error was thrown\n} catch {\n    // an error was thrown\n}\n\nenum SandwichError: Error {\n    case OutOfCleanDishes\n    case MissingIngredients([String])\n}\n\nfunc makeASandwich() throws {\n    throw SandwichError.MissingIngredients([\"butter\",\"ham\",\"bread\"])\n}\nfunc eatASandwich() {\n    print(\"yum yum yum\")\n}\nfunc washDishes() {\n    print(\"Wash the dishes\")\n}\nfunc buyGroceries(ingredients: [String]) {\n    ingredients.forEach{ i in print(i) }\n}\n\ndo {\n    try makeASandwich()\n    eatASandwich()\n} catch SandwichError.OutOfCleanDishes {\n    washDishes()\n} catch SandwichError.MissingIngredients(let ingredients) {\n    buyGroceries(ingredients: ingredients)\n} catch {\n    print(\"Why did I fail\")\n}\n\n//: ## Assertions and Preconditions\n//: ### Debugging with Assertions\n//: Use an assertion whenever a condition has the potential to be false, but must definitely be true in order for your code to continue execution.\nlet age = -3\n//assert(age >= 0, \"A person's age cannot be less than zero\")\n// Left this out as it stops the REPL from continuing\n\n//: ### Enforcing Preconditions\nvar index = -3\nprecondition(index > 0, \"Index must be greater than zero.\")\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/01-TheBasics.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx' display-mode='raw'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/02-BasicOperators.playground/Contents.swift",
    "content": "// Basic Operators\n\n// Assignment operator\nlet b = 10\nvar a = 5\na = b\n\nlet (x, y) = (1, 2)\n\n/*\n// “Unlike the assignment operator in C and Objective-C, the assignment operator in Swift does not itself return a value. The following statement is not valid:”\n\nif x = y {\n    \n}\n*/\n\n// Arithmetic Operators\n1 + 2\n5 - 3\n2 * 3\n10.0 / 2.5\n// Swift Arithmetic operators can't overflow\n\n\"hello, \" + \"world\"\n\nlet dog: Character = \"🐶\"\nlet cow: Character = \"🐮\"\n//let dogcow = dog + cow // This has been removed from the book.\nlet dogcow = \"🐶\" + \"🐮\"\n\n\n// Remainder Operator\n9 % 4\n// a = (b × some multiplier) + remainder\n-9 % 4\n// a % b and a % -b\n9 % -4\n-9 % -4\n\n// Unary Minus Operator\nlet three = 3\nlet minusThree = -three\nlet plusThree = -minusThree\n\n// Unary Plus Operator\n// Doesn't do anything\nlet minusSix = -6\nlet alsoMinusSix = +minusSix\n\n// Compound Assignment Operators\nvar aaa = 1\naaa += 2\n\n// Comparison Operators\n1 == 1\n2 != 1\n2 > 1\n1 < 2\n1 >= 1\n2 <= 1\n\nlet name = \"world\"\nif name == \"world\" {\n    print(\"hello, world\")\n} else {\n    print(\"I'm sorry \\(name), but I don't recognize you\")\n}\n\n// Identity operators\n// “Swift also provides two identity operators (=== and !==), which you use to test whether two object references both refer to the same object instance.”\n\n// Ternary Conditional Operator\nlet contentHeight = 40\nlet hasHeader = true\nlet rowHeight = contentHeight + (hasHeader ? 50 : 20)\n\n// Range Operators\n// The Closed Range Operator\nfor index in 1...5 {\n    print(\"\\(index) times 5 is \\(index * 5)\")\n}\n\n// The Half-Closed range operator\nlet names = [\"Anna\", \"Alex\", \"Brian\", \"Jack\"]\nlet count = names.count\nfor i in 0..<count {\n    print(\"Person \\(i + 1) is called \\(names[i])\")\n}\n\n// One-Sided ranges\nfor name in names[2...] {\n    print(name)\n}\n// Brian\n// Jack\n \nfor name in names[...2] {\n    print(name)\n}\n// Anna\n// Alex\n// Brian\n\nfor name in names[..<2] {\n    print(name)\n}\n// Anna\n// Alex\n\n\n// Logical Operators\nlet allowedEntry = false\nif !allowedEntry {\n    print(\"ACCESS DENIED\")\n}\n\nlet enteredDoorCode = true\nlet passedRetinaScan = false\nif enteredDoorCode && passedRetinaScan {\n    print(\"Welcome!\")\n} else {\n    print(\"ACCESS DENIED\")\n}\n\nlet hasDoorKey = false\nlet knowsOverridePassword = true\nif hasDoorKey || knowsOverridePassword {\n    print(\"Welcome\")\n} else {\n    print(\"ACCESS DENIED\")\n}\n\nif enteredDoorCode && passedRetinaScan || hasDoorKey || knowsOverridePassword {\n    print(\"Welcome!\")\n} else {\n    print(\"ACCESS DENIED\")\n}\n\nif (enteredDoorCode && passedRetinaScan) || hasDoorKey || knowsOverridePassword {\n    print(\"Welcome!\")\n} else {\n    print(\"ACCESS DENIED\")\n}\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/02-BasicOperators.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/02-BasicOperators.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/03-StringsAndCharacters.playground/Contents.swift",
    "content": "// Strings and Characters\n\nlet someString = \"Some tring literal value\"\n\nlet quotation = \"\"\"\nThe White Rabbit put on his spectacles. \"Where shall I begin,\nplease your Majesty?\" he asked.\n\n\"Begin at the beginning,\" the king said gravely, \"and go on\ntill you come to the end; then stop.\"\n\"\"\"\n\nlet threeDoubleQuotes = \"\"\"\nEscaping the first quote \\\"\"\"\nEscaping all three quotes \\\"\\\"\\\"\n\"\"\"\n\nlet singleLineString = \"These are the same.\"\nlet mutilineString = \"\"\"\nThese are the same.\n\"\"\"\n\n\"\"\"\n\nThis string starts with a line feed.\nIt also ends with a line feed.\n\n\"\"\"\n\nfunc generateQuotation() -> String {\n    let quotation = \"\"\"\n        The White Rabbit put on his spectacles. \"Where shall I begin,\n        please your Majesty?\" he asked.\n\n        \"Begin at the beginning,\" the king said gravely, \"and go on\n        till you come to the end; then stop.\"\n        \"\"\"\n    return quotation\n}\nprint(quotation == generateQuotation())\n\n\n// Initializing an Empty Strings\nvar emptyString = \"\"\nvar anotherEmpyString = String()\nif emptyString.isEmpty {\n    print(\"Nothing to see here\")\n}\n\n\n// String mutability\nvar variableString = \"Horse\"\nvariableString += \" and carriage\"\n\nlet constantString = \"Highlander\"\n// constantString += \" and another Highlander\" // There can be only one\n\n\n// Working with Characters\nfor character in \"Dog!🐶\".characters {\n    print(character)\n}\n\nlet exclamationMark: Character = \"!\"\n\nlet catCharacters: [Character] = [\"C\", \"a\", \"t\", \"!\", \"🐱\"]\nlet catString = String(catCharacters)\nprint(catString)\ncatString\n\n\n// Concatenating Strings and Characters\nlet string1 = \"Hello\"\nlet string2 = \" there\"\nvar welcome = string1 + string2\n// Welcome now equals \"hellow there\"\n\nvar instruction = \"look over\"\ninstruction += string2\n\nwelcome.append(exclamationMark)\n\n\n// String Interpolation\nlet multiplier = 3\nlet message = \"\\(multiplier) times 2.5 is \\(Double(multiplier) * 2.5)\"\n\n\n// Special Characters in String LIterals\nlet wiseWords = \"\\\"Imagination is more important than knowledge\\\" - Einstein\"\n// \"Imagination is more important than knowledge\" - Einstein\nlet dollarSign = \"\\u{24}\"           // $,  Unicode scalar U+0024\nlet blackHeart = \"\\u{2665}\"         // ♥,  Unicode scalar U+2665\nlet sparklingHeart = \"\\u{1F496}\"    // 💖, Unicode scalar U+1F496\n\n\n// Extended Grapheme Clusters\nlet eAcute: Character = \"\\u{E9}\"                // é\nlet combinedEAcute: Character = \"\\u{65}\\u{301}\" // e followed by ́\n// eAcute is é, combinedEAcute is é\n\nlet precomposed: Character = \"\\u{D55C}\"                 // 한\nlet decomposed: Character = \"\\u{1112}\\u{1161}\\u{11AB}\"  // ᄒ, ᅡ, ᆫ\n// precomposed is 한, decomposed is 한\n\nlet enclosedEAcute: Character = \"\\u{E9}\\u{20DD}\"\n// enclosedEAcute is é⃝\n\nlet regionalIndicatorForUS: Character = \"\\u{1F1FA}\\u{1F1F8}\"\n// regionalIndicatorForUS is 🇺🇸\n\nlet regionalIndicatorForAUS: Character = \"\\u{1F1E6}\\u{1F1FA}\"\n// regionalIndicatorForAUS is 🇦🇺\n\n\n// Counting Characters\nlet unusualMenagerie = \"Koala 🐨, Snail 🐌, Penguin 🐧, Dromedary 🐪\"\nprint(\"unusualMenagerie has \\(unusualMenagerie.characters.count) characters\")\n// prints \"unusualMenagerie has 40 characters\"\n\n// Note that Swift's use of extended grapheme clusters for Character values means that string concatenation and modification may not always affect a string's character count.\n\nvar word = \"cafe\"\nprint(\"the number of characters in \\(word) is \\(word.characters.count)\")\n// prints \"the number of characters in cafe is 4\"\n\nword += \"\\u{301}\" // Combining Acute accent, U+301\n\nprint(\"the number of characters in \\(word) is \\(word.characters.count)\")\n// prints \"the number of characters in café is 4\"\n\n\n// Accessing and Modifying a String\n// String Indices\n// Different characters can require different amounts of memory to store, so in order to determine which Character is at a particular position, you must iterate over each Unicode scalar from the start or end of that String. For this reaason, Swift strings cannot be indexed by integer values.\n\nlet greeting = \"Guten Tag!\"\ngreeting[greeting.startIndex]                               // G\ngreeting[greeting.index(before: greeting.endIndex)]         // !\ngreeting[greeting.index(after: greeting.startIndex)]        // u\nlet index = greeting.index(greeting.startIndex, offsetBy: 7)\ngreeting[index]                                             // a\n// greeting[greeting.endIndex]                              // error\n// greeting.endIndex.successor()                            // error\n\nfor index in greeting.characters.indices {\n    print(\"\\(greeting[index]) \", terminator: \"\")\n}\n// prints \"G u t e n  T a g !\"\n\n\n// Inserting and Removing\n// To insert a character at a specified index.\nvar welcome2 = \"hello\"\nwelcome2.insert(\"!\", at: welcome2.endIndex)\n\n// To insert another string at a specified index\nwelcome2.insert(contentsOf:\" there\".characters, at: welcome2.index(before: welcome2.endIndex))\n\n// To remove a character at a specified index\nwelcome2.remove(at: welcome2.index(before: welcome2.endIndex))\nwelcome2\n\n// To remove a substring\nlet range = welcome2.index(welcome2.endIndex, offsetBy: -6)..<welcome2.endIndex\nwelcome2.removeSubrange(range)\n\n\n// Comparing Strings\nlet quotation2 = \"We're a lot alike, you and I.\"\nlet sameQuotation = \"We're a lot alike, you and I.\"\nif quotation2 == sameQuotation {\n    print(\"These two strings are considered equal\")\n}\n// Two String values are considered equal if their extended grapheme clusters are canonically equivalent (if they have the same linguistic meaning and appearance, even if the are composed from different Unicode scalars).\n\n// \"Voulez-vous un café?\" using LATIN SMALL LETTER E WITH ACUTE\nlet eAcuteQuestion = \"Voulez-vous un caf\\u{E9}?\"\n\n// \"Voulez-vous un café?\" using LATIN SMALL LETTER E and COMBINING ACUTE ACCENT\nlet combinedEAcuteQuestion = \"Voulez-vous un caf\\u{65}\\u{301}?\"\nlet combinedEAcuteQuestion2 = \"Voulez-vous un cafe\\u{301}?\"\n\nif eAcuteQuestion == combinedEAcuteQuestion {\n    print(\"These two strings are considered equal\")\n}\n\n// Conversely, characters that are visually similar but do not have the same linguistic meaning are not considered equal.\nlet latinCapitalLeterA: Character = \"\\u{41}\"\nlet cyrillicCapitalLetterA: Character = \"\\u{0410}\"\nif latinCapitalLeterA != cyrillicCapitalLetterA {\n    print(\"These two characters are not equivalent\")\n}\n\n\n// Prefix and Suffix Equality\nlet romeoAndJuliet = [\n    \"Act 1 Scene 1: Verona, A public place\",\n    \"Act 1 Scene 2: Capulet's mansion\",\n    \"Act 1 Scene 3: A room in Capulet's mansion\",\n    \"Act 1 Scene 4: A street outside Capulet's mansion\",\n    \"Act 1 Scene 5: The Great Hall in Capulet's mansion\",\n    \"Act 2 Scene 1: Outside Capulet's mansion\",\n    \"Act 2 Scene 2: Capulet's orchard\",\n    \"Act 2 Scene 3: Outside Friar Lawrence's cell\",\n    \"Act 2 Scene 4: A street in Verona\",\n    \"Act 2 Scene 5: Capulet's mansion\",\n    \"Act 2 Scene 6: Friar Lawrence's cell\"\n]\nvar act1SceneCount = 0\nfor scene in romeoAndJuliet {\n    if scene.hasPrefix(\"Act 1\") {\n        act1SceneCount += 1\n    }\n}\nprint(\"There are \\(act1SceneCount) scenes in Act 1\")\n\nvar mansionCount = 0\nvar cellCount = 0\nfor scene in romeoAndJuliet {\n    if scene.hasSuffix(\"Capulet's mansion\") {\n        mansionCount += 1\n    } else if scene.hasSuffix(\"Friar Lawrence's cell\") {\n        cellCount += 1\n    }\n}\nprint(\"\\(mansionCount) mansion scenes; \\(cellCount) cell scenes\")\n\n\n// Unicode Representations of Strings\nlet dogString = \"Dog!!🐶\"\n\n// UTF-8 Representation\nfor codeUnit in dogString.utf8 {\n    print(\"\\(codeUnit) \", terminator: \"\")\n}\nprint(\"\")\n\n// UTF-16 Representation\nfor codeUnit in dogString.utf16 {\n    print(\"\\(codeUnit) \", terminator: \"\")\n}\nprint(\"\")\n\n// Unicode Scalar Representation\nfor scalar in dogString.unicodeScalars {\n    print(\"\\(scalar.value) \", terminator: \"\")\n}\nprint(\"\")\n\nfor scalar in dogString.unicodeScalars {\n    print(\"\\(scalar)\")\n}\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/03-StringsAndCharacters.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/04-CollectionTypes.playground/Contents.swift",
    "content": "// Collection Types\n\n// Arrays\n// Creating an Empty Array\nvar someInts = [Int]()\nprint(\"someInts is of type [Int] with \\(someInts.count) items.\")\n\n// Creating an Array with a Default Value\nvar threeDoubles = Array(repeating: 0.0, count: 3)\n\n// Creating an Array by Adding Two Arrays Together\nvar anotherThreeDoubles = Array(repeating: 2.5, count: 3)\nvar sixDoubles = threeDoubles + anotherThreeDoubles\n\n// Creating an Array with an Array Literal\nvar shoppingList: [String] = [\"Eggs\",\"Milk\"]\n\n\n// Accessing and Modifying an Array\nprint(\"The shopping list contains \\(shoppingList.count) items.\")\n\nif shoppingList.isEmpty {\n    print(\"The shopping list is empty.\")\n} else {\n    print(\"The shopping list is not empty\")\n}\n\nshoppingList.append(\"Flour\")\nshoppingList += [\"Baking Powder\"]\n\nshoppingList += [\"Chocolate Spread\", \"Cheese\", \"Butter\"]\n\nvar firstItem = shoppingList[0]\nshoppingList[0] = \"Six eggs\"\n\nshoppingList[4...6] = [\"Bananas\", \"Apples\"]\n\nshoppingList.insert(\"Maple Syrup\", at: 0)\n\nlet mapleSyrup = shoppingList.remove(at: 0)\nfirstItem = shoppingList[0]\n\nlet apples = shoppingList.removeLast()\n\n\n// Iterating Over an Array\nfor item in shoppingList {\n    print(item)\n}\n\nfor (index, value) in shoppingList.enumerated() {\n    print(\"Item \\(index + 1): \\(value)\")\n}\n\n\n\n// Sets\n// Hash Values for Set Types\n// A type must be hashable in order to be stored in a set.\n\n// Creating and Initializing an Empty Set\nvar letters = Set<Character>()\nprint(\"letters is of type Set<Character> with \\(letters.count) items.\")\n\nletters.insert(\"a\")\nletters = []\n// letters is now an empty set, but is still of type Set<Character>\n\n// Creating a Set with an Array Literal\nvar favoriteGenres: Set<String> = [\"Rock\", \"Classical\", \"Hip hop\"]\nlet alsoFavoriteGenres: Set = [\"Rock\", \"Classical\", \"Hip hop\"]\n\n// Accessing and Modifying a Set\nprint(\"I have \\(favoriteGenres.count) favorite music genres.\")\n\nif favoriteGenres.isEmpty {\n    print(\"As far as music goes, I'm not picky.\")\n} else {\n    print(\"I have particular music preferences.\")\n}\n\nfavoriteGenres.insert(\"Jazz\")\n\nif let removedGenre = favoriteGenres.remove(\"Rock\") {\n    print(\"\\(removedGenre)? I'm over it.\")\n} else {\n    print(\"I never much cared for that.\")\n}\n\nif favoriteGenres.contains(\"Funk\") {\n    print(\"I get up on the good foot.\")\n} else {\n    print(\"It's too funky in here.\")\n}\n\n// Iterating Over a Set\nfor genre in favoriteGenres {\n    print(\"\\(genre)\")\n}\n\nfor genre in favoriteGenres.sorted() {\n    print(\"\\(genre)\")\n}\n\n//for genre in favoriteGenres.sorted({ $0[$0.endIndex.predecessor()] > $1[$1.endIndex.predecessor()] }) {\n//    print(\"\\(genre)\")\n//}\n\nfor genre in favoriteGenres.sorted().reversed() {\n    print(\"\\(genre)\")\n}\n\n// Performing Set Operations\nlet oddDigits: Set = [1,3,5,7,9]\nlet evenDigits: Set = [0,2,4,6,8]\nlet singleDigitPrimeNumbers: Set = [2,3,5,7]\n\noddDigits.union(evenDigits).sorted()\noddDigits.intersection(evenDigits).sorted()\noddDigits.subtracting(singleDigitPrimeNumbers).sorted()\noddDigits.symmetricDifference(singleDigitPrimeNumbers).sorted()\n\n// Set Membership and Equality\n// Set a is a superset of set b, because a contains all elements of b\n// Set b is a subset of a\n// Set b and set c are disjoint with one another as they share no elements in common\n\nlet houseAnimals: Set = [\"🐶\", \"🐱\"]\nlet farmAnimals: Set = [\"🐮\", \"🐔\", \"🐑\", \"🐶\", \"🐱\"]\nlet cityAnimals: Set = [\"🐦\", \"🐭\"]\n\nhouseAnimals.isSubset(of: farmAnimals)\nfarmAnimals.isSuperset(of: houseAnimals)\nfarmAnimals.isDisjoint(with: cityAnimals)\n\n\n\n// Dictionaries\nlet alongFormDict = Dictionary<String, Int>()\nlet shortFormDict = [String:Int]()\n\n// Creating an Empty Dictionary\nvar namesOfIntegers = [Int: String]()\n\nnamesOfIntegers[16] = \"sixteen\"\nnamesOfIntegers = [:]\n\n// Creating a Dictionary with a Dictionary Literal\n//var airports: Dictionary<String, String> = [\"TYO\":\"Tokyo\", \"DUB\":\"Dublin\"]\nvar airports: [String: String] = [\"YYZ\":\"Toronto Pearson\", \"DUB\":\"Dublin\"]\n\n// Accessing and Modifying a Dictionary\nprint(\"The dictionary of airports contains \\(airports.count) items.\")\n\nif airports.isEmpty {\n    print(\"The airports dictionary is empty.\")\n} else {\n    print(\"The airports dictionary is not empty.\")\n}\n\nairports[\"LHR\"] = \"London\"\nairports[\"LHR\"] = \"London Heathrow\"\n\nif let oldValue = airports.updateValue(\"Dublin International\", forKey: \"DUB\") {\n    print(\"The old value for DUB was \\(oldValue).\")\n}\n\nif let airportName = airports[\"DUB\"] {\n    print(\"The name of the airport is \\(airportName)\")\n} else {\n    print(\"That airport is not in the airports dictionary.\")\n}\n\nairports[\"APL\"] = \"Apple International\"\nairports[\"APL\"] = nil\n\nif let removedValue = airports.removeValue(forKey: \"DUB\") {\n    print(\"The removed airport's name is \\(removedValue).\")\n} else {\n    print(\"The airports dictionary does not contain a value for DUB.\")\n}\n\n// Iterating over a dictionary\nfor (airportCode, airportName) in airports {\n    print(\"\\(airportCode): \\(airportName)\")\n}\n\nfor airportCode in airports.keys {\n    print(\"Airport code: \\(airportCode)\")\n}\n\nfor airportName in airports.values {\n    print(\"Airport name: \\(airportName)\")\n}\n\nlet airportCodes = [String](airports.keys)\nlet airportNames = [String](airports.values)\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/04-CollectionTypes.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/05-ControlFlow.playground/Contents.swift",
    "content": "// Control Flow Chapter\n\n// For Loops\n// For-In\nfor index in 1...5 {\n    print(\"\\(index) times 5 is \\(index * 5)\")\n}\n\nlet base = 3\nlet power = 10\nvar answer = 1\nfor _ in 1...power {\n    answer *= base\n}\n\nlet names = [\"Anna\", \"Alex\", \"Brian\", \"Jack\"]\nfor name in names {\n    print(\"Hello, \\(name)!\")\n}\n\nlet numberOfLegs = [\"spider\": 8, \"ant\": 6, \"cat\": 4]\nfor (animalName, legCount) in numberOfLegs {\n    print(\"\\(animalName)s have \\(legCount) legs\")\n}\n\n\n// While Loops\n// While\nlet finalSquare = 25\nvar board = [Int](repeating: 0, count: finalSquare + 1)\nboard[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02\nboard[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08\n\nvar square = 0\nvar diceRoll = 0\nwhile square < finalSquare {\n    // roll the dice\n    diceRoll += 1\n    if diceRoll == 7 { diceRoll = 1 }\n    // move by the rolled amount\n    square += diceRoll\n    if square < board.count {\n        // if we're still on the board, move up or down for a snake or a ladder\n        square += board[square]\n    }\n}\nprint(\"Game over!\")\n\n// Repeat-While\nsquare = 0\ndiceRoll = 0\nrepeat {\n    // move up or down for a snake or ladder\n    square += board[square]\n    // roll the dice\n    diceRoll += 1\n    if diceRoll == 7 { diceRoll = 1 }\n    // move by the rolled amount\n    square += diceRoll\n} while square < finalSquare\nprint(\"Game over!\")\n\n\n// Conditional Statements\n// If\nvar temperatureInFarenheit = 30\nif temperatureInFarenheit <= 32 {\n    print(\"It's very cold. Consider wearing a scarf\")\n}\n\ntemperatureInFarenheit = 40\nif temperatureInFarenheit <= 32 {\n    print(\"It's very cold. Consider wearing a scarf\")\n} else {\n    print(\"It's not that cold. wear a t-shirt.\")\n}\n\ntemperatureInFarenheit = 90\nif temperatureInFarenheit <= 32 {\n    print(\"It's very cold. Consider wearing a scarf\")\n} else if temperatureInFarenheit >= 86 {\n    print(\"It's really warm. Don't forget to wear sunscreen.\")\n} else {\n    print(\"It's not that cold. wear a t-shirt.\")\n}\n\ntemperatureInFarenheit = 72\nif temperatureInFarenheit <= 32 {\n    print(\"It's very cold. Consider wearing a scarf\")\n} else if temperatureInFarenheit >= 86 {\n    print(\"It's really warm. Don't forget to wear sunscreen.\")\n}\n\n\n// Switch\nlet someCharacter: Character = \"e\"\nswitch someCharacter {\n    case \"a\", \"e\", \"i\", \"o\", \"u\":\n        print(\"\\(someCharacter) is a vowel\")\n    case \"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\":\n        print(\"\\(someCharacter) is a consonant\")\n    default:\n        print(\"\\(someCharacter) is not a vowel or consonant\")\n}\n\n// No Implicit Fallthrough\nlet anotherCharacter: Character = \"a\"\nswitch anotherCharacter {\n    //case \"a\": // Not valid if this line is in place as no executble line for this case statement.\n    case \"A\":\n        print(\"The letter A\")\n    default:\n        print(\"Not the letter A\")\n}\n\n\n// Interval Matching\nlet approximateCount = 62\nlet countedThings = \"moons orbitiy Saturn\"\nvar naturalCount: String\nswitch approximateCount {\ncase 0:\n    naturalCount = \"no\"\ncase 1..<5:\n    naturalCount = \"a few\"\ncase 5..<12:\n    naturalCount = \"several\"\ncase 12..<100:\n    naturalCount = \"dozens of\"\ncase 100..<1000:\n    naturalCount = \"hundreds of\"\ndefault:\n    naturalCount = \"manu\"\n}\nprint(\"There are \\(naturalCount) \\(countedThings).\")\n// Note: Both the closed range operator (...) and half-open range operator (..<) functions are overloaded to return either an IntervalType or Range. An interval can determine whether it contains a particular element, such as when matching a switch statement case. A range is a collecton of consecutive values, which can be iterated on in a for-in statement.\n\n\n// Tuples\nlet somePoint = (1,1)\nswitch somePoint {\ncase (0, 0):\n    print(\"(0,0) is at the origin\")\ncase (_, 0):\n    print(\"\\(somePoint.0),0) is on the x-axis\")\ncase (0, _):\n    print(\"(0, \\(somePoint.1)) is on the y-axis\")\ncase (-2...2, -2...2):\n    print(\"(\\(somePoint.0, somePoint.1)) is inside the box\")\ndefault:\n    print(\"(\\(somePoint.0, somePoint.1)) is outside of the box\")\n}\n\n\n// Value Bindings\nlet anotherPoint = (2, 0)\nswitch anotherPoint {\ncase (let x, 0):\n    print(\"on the x-axis with an x value of \\(x)\")\ncase (0, let y):\n    print(\"on the y-axis with a y value of \\(y)\")\ncase let (x, y):\n    print(\"somewhare else at (\\(x), \\(y))\")\n}\n\n\n// Where\nlet yetAnotherPoint = (1, -1)\nswitch yetAnotherPoint {\ncase let (x, y) where x == y:\n    print(\"(\\(x), \\(y)) is on the line x == y\")\ncase let (x, y) where x == -y:\n    print(\"(\\(x), \\(y)) is on the line x == -y\")\ncase let (x, y):\n    print(\"(\\(x), \\(y)) is just some arbitrary point\")\n}\n\n\n// Control Transfer Statements\n// Continue\nlet puzzleInput = \"great minds think alike\"\nvar puzzleOutput = \"\"\nfor character in puzzleInput.characters {\n    switch character {\n        case \"a\", \"e\", \"i\", \"o\", \"u\", \" \":\n            continue\n    default:\n        puzzleOutput.append(character)\n    }\n}\npuzzleOutput\n\n// Break\nlet numberSymbol: Character = \"三\"  // Simplified Chinese for the number 3”\nvar possibleIntegerValue: Int?\nswitch numberSymbol {\ncase \"1\", \"١\", \"一\", \"๑\":\n    possibleIntegerValue = 1\ncase \"2\", \"٢\", \"二\", \"๒\":\n    possibleIntegerValue = 2\ncase \"3\", \"٣\", \"三\", \"๓\":\n    possibleIntegerValue = 3\ncase \"4\", \"٤\", \"四\", \"๔\":\n    possibleIntegerValue = 4\ndefault:\n    break\n\n}\nif let integerValue = possibleIntegerValue {\n    print(\"The integer value of \\(numberSymbol) is \\(integerValue).\")\n} else {\n    print(\"An integer value could not be found for \\(numberSymbol).\")\n}\n\n// Fallthrough\nlet integerToDescribe = 5\nvar description = \"The number \\(integerToDescribe) is\"\nswitch integerToDescribe {\ncase 2, 3, 5, 7, 11, 13, 17, 19:\n    description += \" a prime number, and also\"\n    fallthrough\ndefault:\n    description += \" an integer.\"\n}\nprint(description)\n\n\n// Labelled Statements\nboard = [Int](repeating: 0, count: finalSquare + 1)\nboard[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02\nboard[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08\nsquare = 0\ndiceRoll = 0\n\ngameLoop: while square != finalSquare {\n    diceRoll += 1\n    if diceRoll == 7 { diceRoll = 1}\n    switch square + diceRoll {\n    case finalSquare:\n        break gameLoop\n    case let newSquare where newSquare > finalSquare:\n        continue gameLoop\n    default:\n        square += diceRoll\n        square += board[square]\n    }\n}\nprint(\"Game over!\")\n\n\n// Early Exit\n// Guard\nfunc greet(person: [String: String]) {\n    guard let name = person[\"name\"] else {\n        return\n    }\n    \n    print(\"Hello \\(name)!\")\n    \n    guard let location = person[\"location\"] else {\n        print(\"I hope the weather is nice near you.\")\n        return\n    }\n    \n    print(\"I hope the weather is nice in \\(location).\")\n}\ngreet(person: [:])\ngreet(person: [\"name\": \"John\"])\ngreet(person: [\"name\":\"Jane\", \"location\": \"Cupertino\"])\n\n\n// Checking API Availability\nif #available(iOS 9, OSX 10.12, *) {\n    print(\"Use iOS 9 APIs on iOS, and use OS X v10.10 APIs on OS X\")\n} else {\n    print(\"Fall back to earlier iOS and OSX APIs\")\n}\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/05-ControlFlow.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/05-ControlFlow.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n      <LoggerValueHistoryTimelineItem\n         documentLocation = \"#CharacterRangeLen=0&amp;CharacterRangeLoc=78&amp;EndingColumnNumber=10&amp;EndingLineNumber=12&amp;StartingColumnNumber=4&amp;StartingLineNumber=12&amp;Timestamp=456018830.746211\"\n         selectedRepresentationIndex = \"0\"\n         shouldTrackSuperviewWidth = \"NO\">\n      </LoggerValueHistoryTimelineItem>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/06-Functions.playground/Contents.swift",
    "content": "//: # Functions Chapter\n\nfunc greet(person: String) -> String {\n    let greeting = \"Hello, \" + person + \"!\"\n    return greeting\n}\nprint(greet(person: \"Anna\"))\nprint(greet(person: \"Brian\"))\n\nfunc greetAgain(person: String) -> String {\n    return \"Hello, \" + person + \"!\"\n}\nprint(greetAgain(person: \"Anna\"))\n\n\n// Function Parameters and Return Values\n// Functions Without Parameters\nfunc sayHelloWorld() -> String {\n    return \"hello, world\"\n}\nprint(sayHelloWorld())\n\n// Multiple Input Parameters\nfunc greet(person: String, alreadyGreeted: Bool) -> String {\n    if alreadyGreeted {\n        return greetAgain(person: person)\n    } else {\n        return greet(person: person)\n    }\n}\nprint(greet(person: \"Time\", alreadyGreeted: true))\n\n// Functions Without Return Values\nfunc greet2(person: String) {\n    print(\"Hello, \\(person)!\")\n}\ngreet2(person: \"Dave\")\n\nfunc printAndCount(string: String) -> Int {\n    print(string)\n    return string.characters.count\n}\nfunc printWithoutCounting(string: String) {\n    let _ = printAndCount(string: string)\n}\nprintAndCount(string: \"hello, world\")\nprintWithoutCounting(string: \"hello, world\")\n\n// Functions with Multiple Return Values\nfunc minMax(array: [Int]) -> (min: Int, max: Int) {\n    var currentMin = array[0]\n    var currentMax = array[0]\n    for value in array[1..<array.count] {\n        if value < currentMin {\n            currentMin = value\n        } else if value > currentMax {\n            currentMax = value\n        }\n    }\n    return (currentMin, currentMax)\n}\nlet bounds = minMax(array: [8, -6, 2, 109, 3, 71])\nprint(\"min is \\(bounds.min) and max is \\(bounds.max)\")\n\n// Optional Tuple Return Types\nfunc minMaxSafe(array: [Int]) -> (min: Int, max: Int)? {\n    if array.isEmpty {return nil }\n    var currentMin = array[0]\n    var currentMax = array[0]\n    for value in array[1..<array.count] {\n        if value < currentMin {\n            currentMin = value\n        } else if value > currentMax {\n            currentMax = value\n        }\n    }\n    return (currentMin, currentMax)\n}\nif let bounds = minMaxSafe(array: [8, -6, 2, 109, 3, 71]) {\n    print(\"min is \\(bounds.min) and max is \\(bounds.max)\")\n}\n\n// Function Argument Labels and Parameter Names\n// External Parameter Names\nfunc someFunction(firstParameterName: Int, secondParameterName: Int) {\n    \n}\nsomeFunction(firstParameterName: 1, secondParameterName: 2)\n\n// Secifying Argument Labels\nfunc greet(person: String, from hometown: String) -> String {\n    return \"Hello \\(person)! Glad you could visit from \\(hometown).\"\n}\ngreet(person: \"Bill\", from: \"Cupertino\")\n\n// Omitting Argument Labels\nfunc someFunction(_ firstParameterName: Int, secondParameterName: Int) {\n    \n}\nsomeFunction(1, secondParameterName: 2)\n\n// Default Parameter Values\nfunc someFunction(parameterWithoutDefault: Int, parameterWithDefault: Int = 12) {\n    \n}\nsomeFunction(parameterWithoutDefault: 3, parameterWithDefault: 6)\nsomeFunction(parameterWithoutDefault: 4)\n\n\n// Variadic Parameters\nfunc arithmeticMean(_ numbers: Double...) -> Double {\n    var total: Double = 0\n    for number in numbers {\n        total += number\n    }\n    return total / Double(numbers.count)\n}\narithmeticMean(1, 2, 3, 4, 5)\narithmeticMean(3, 8, 19)\n\n\n// In-Out Parameters\nfunc swapTwoInts(_ a: inout Int, _ b: inout Int) {\n    let temporaryA = a\n    a = b\n    b = temporaryA\n}\nvar someInt = 3\nvar anotherInt = 107\nswapTwoInts(&someInt, &anotherInt)\nprint(\"someInt is now \\(someInt), and anotherInt is now \\(anotherInt)\")\n\n\n// Function Types\n//  Every function has a specific function type, made up of the parameter types and the return type of the function.\nfunc addTwoInts(_ a: Int, _ b: Int) -> Int {\n    return a + b\n}\nfunc multiplyTwoInts(_ a: Int, _ b: Int) -> Int {\n    return a * b\n}\n\nfunc printHelloWorld() {\n    print(\"hello, world\")\n}\n\n// Using Function Types\n//  you can define a constant or variable to be of a function type and assign an appropriate function to that variable:\nvar mathFunction: (Int, Int) -> Int = addTwoInts\nprint(\"Result: \\(mathFunction(2, 3))\")\n\nmathFunction = multiplyTwoInts\nprint(\"Result: \\(mathFunction(2, 3))\")\n\nlet anotherMathFunction = addTwoInts\n\n// Function Types as Parameter Types\nfunc printMathResult(_ mathFunction: (Int, Int) -> Int, _ a: Int, _ b: Int) {\n    print(\"Result: \\(mathFunction(a, b))\")\n}\nprintMathResult(addTwoInts, 3, 5)\n\n// Function Types as Return Types\nfunc stepForward(_ input: Int) -> Int {\n    return input + 1\n}\nfunc stepBackward(_ input: Int) -> Int {\n    return input - 1\n}\n\nfunc chooseStepFunction(backward: Bool) -> (Int) -> Int {\n    return backward ? stepBackward : stepForward\n}\n\nvar currentValue = 3\nlet moveNearerToZero = chooseStepFunction(backward: currentValue > 0)\n\nprint(\"Counting to zero:\")\nwhile currentValue != 0 {\n    print(\"\\(currentValue)... \")\n    currentValue = moveNearerToZero(currentValue)\n}\nprint(\"zero!\")\n\n\n// Nested Functions\nfunc chooseAnotherStepFunction(backward: Bool) -> (Int) -> Int {\n    func stepForward(input: Int) -> Int { return input + 1 }\n    func stepBackward(input: Int) -> Int { return input - 1 }\n    return backward ? stepBackward : stepForward\n}\ncurrentValue = -4\nlet moveNearerToZeroAgain = chooseAnotherStepFunction(backward: currentValue > 0)\nwhile currentValue != 0 {\n    print(\"\\(currentValue)... \")\n    currentValue = moveNearerToZeroAgain(currentValue)\n}\nprint(\"zero!\")\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/06-Functions.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/07-Closures.playground/Contents.swift",
    "content": "// Closures Chapter from From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/au/jEUH0.l\n\n//  Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.\n\n// Closure Expressions\n// The Sort Function\nlet names = [\"Chris\", \"Alex\", \"Ewa\", \"Barry\", \"Daniella\"]\n\nfunc backward(s1: String, s2: String) -> Bool {\n    return s1 > s2\n}\nvar reversedNames = names.sorted(by: backward)\n\n// Closure Expression Syntax\nreversedNames = names.sorted(by: { (s1:String, s2: String) -> Bool in return s1 > s2 })\n\n// Inferring Type from from Context\nreversedNames = names.sorted(by: { s1, s2 in return s1 > s2 })\n\n// Implicit returns from Single-Expression Closures\nreversedNames = names.sorted(by: { s1, s2 in s1 > s2 })\n\n// Shorthand Argument Names\nreversedNames = names.sorted(by: { $0 > $1 })\n\n// Operator Functions\nreversedNames = names.sorted(by: >)\n\n\n// Trailing Closures\nfunc someFunctionThatTakesAClosure(closure: () -> ()) {\n    \n}\nsomeFunctionThatTakesAClosure(closure: {})\nsomeFunctionThatTakesAClosure() {\n    \n}\n\nreversedNames = names.sorted() { $0 > $1 }\nreversedNames = names.sorted { $0 > $1 }\n\nlet digitNames = [\n    0: \"Zero\", 1: \"One\", 2: \"Two\", 3: \"Three\", 4:\"Four\",\n    5: \"Five\", 6:\"Six\", 7: \"Seven\", 8: \"Eight\", 9: \"Nine\"\n]\nlet numbers = [16, 58, 510]\n\nlet strings = numbers.map {\n    (number) -> String in\n    var number = number\n    var output = \"\"\n    repeat {\n        output = digitNames[number % 10]! + output\n        number /= 10\n    } while number > 0\n    return output\n}\nstrings\n\n\n// Capturing Values\nfunc makeIncrementer(forIncrement amount: Int) -> () -> Int {\n    var runningTotal = 0\n    func incrementer() -> Int {\n        runningTotal += amount\n        return runningTotal\n    }\n    return incrementer\n}\nlet incrementByTen = makeIncrementer(forIncrement: 10)\nincrementByTen()\nincrementByTen()\nincrementByTen()\nlet incrementBySeven = makeIncrementer(forIncrement: 7)\nincrementBySeven()\nincrementByTen()\n\n// Closures are Reference Types\nlet alsoIncrementByTen = incrementByTen\nalsoIncrementByTen()\n\n// Escaping Closures\nvar completionHandlers: [() -> Void] = []\nfunc soneFunctionWithEscapingClosure(completionHandler: @escaping () -> Void) {\n    completionHandlers.append(completionHandler)\n}\n\nfunc someFunctionWithNonescapingClosure(closure: () -> Void) {\n    closure()\n}\n\nclass SomeClass {\n    var x = 10\n    func doSomething() {\n        soneFunctionWithEscapingClosure { self.x = 100 }\n        someFunctionWithNonescapingClosure { x = 200 }\n    }\n}\n\nlet instance = SomeClass()\ninstance.doSomething()\nprint(instance.x) // Prints \"200\"\n\n//: ## Autoclosures\nvar customersInLine = [\"Chris\", \"Alex\", \"Ewa\", \"Barry\", \"Daniella\"]\nprint(customersInLine.count)\n\nlet customerProvider = { customersInLine.remove(at: 0) }\nprint(customersInLine.count)\n\nprint(\"Now serving \\(customerProvider())!\")\nprint(customersInLine.count)\n\nfunc serve(customer customerProvider: () -> String) {\n    print(\"Now serving \\(customerProvider())!\")\n}\nserve(customer: { customersInLine.remove(at: 0) } )\n\n//: Even though the first element of the customersInLine array is removed as part of the closure, that operation isn't carried out until the closure is actually called. If the closure is never called, the expression inside the closure is never evaluated. Note that the type of nextCustomer is not String but () -> String - a function that takes no arguments and returns a string.\n\nfunc serve(customer customerProvider: @autoclosure () -> String) {\n    print(\"Now serving \\(customerProvider())!\")\n}\nserve(customer: customersInLine.remove(at: 0) )\n\n//: The serveNextCustomer function above takes an explicit closure that returns the next customer's name. The version below performs the same operation but, instead uses an autoclosure. Now you can call the function as if it took a String argument instead of a closure.\n\n\n//: ### @autoclosure(escaping)\n\nvar customerProviders: [() -> String] = []\nfunc collectCustomerProviders(_ customerProvider: @autoclosure @escaping () -> String) {\n    customerProviders.append(customerProvider)\n}\ncollectCustomerProviders(customersInLine.remove(at: 0))\ncollectCustomerProviders(customersInLine.remove(at: 0))\n\nprint(\"Collected \\(customerProviders.count) closures.\")\nfor customerProvider in customerProviders {\n    print(\"Now serving \\(customerProvider())!\")\n}\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/07-Closures.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/08-Enumerations.playground/Contents.swift",
    "content": "// Enumerations\n\n//  An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.\n\nenum CompassPoint {\n    case north\n    case south\n    case east\n    case west\n}\n\nenum Planet {\n    case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune\n}\n\nvar directionToHead = CompassPoint.west\n\ndirectionToHead = .east\n\n\n// Matching Enumeration Values with a Switch Statement\ndirectionToHead = .south\nswitch directionToHead {\ncase .north:\n    print(\"Lots of planets have a north\")\ncase .south:\n    print(\"Watch out for penguins\")\ncase .east:\n    print(\"Where the sun rises\")\ncase .west:\n    print(\"Where the skies are blue\")\n}\n\nlet somePlanet = Planet.earth\nswitch somePlanet {\ncase .earth:\n    print(\"Mostly Harmless\")\ndefault:\n    print(\"Not a safe place for humans\")\n}\n\n// Associated Values\nenum Barcode {\n    case upc(Int, Int, Int, Int)\n    case qrCode(String)\n}\nvar productBarcode = Barcode.upc(8, 85909, 51226, 3)\nproductBarcode = .qrCode(\"ABCDEFGHIJKLMNOP\")\n\nswitch productBarcode {\ncase .upc(let numberSystem, let manufacturer, let product, let check):\n    print(\"UPC: \\(numberSystem), \\(manufacturer), \\(product), \\(check)\")\ncase .qrCode(let productCode):\n    print(\"QR code: \\(productCode).\")\n}\n\nproductBarcode = Barcode.upc(8, 85909, 51226, 3)\nswitch productBarcode {\ncase let .upc(numberSystem, manufacturer, product, check):\n    print(\"UPC : \\(numberSystem), \\(manufacturer), \\(product), \\(check).\")\ncase let .qrCode(productCode):\n    print(\"QR code: \\(productCode).\")\n}\n\n\n// Raw Values\nenum ASCIIControlCharacter: Character {\n    case tab = \"\\t\"\n    case lineFeed = \"\\n\"\n    case carriageReturn = \"\\r\"\n}\n\n// Implicitly Assigned Raw Values\nenum PlanetRaw: Int {\n    case mercury = 1, venus, earth, mars, jupiter, saturn, uranus, neptune\n}\n\nlet earthsOrder = PlanetRaw.earth.rawValue\n// earthsOrder is 3\n\nenum CompassPointRaw: String {\n    case north, south, east, west\n}\nlet sunsetDirection = CompassPointRaw.west.rawValue\n// sunsetDirection is \"West\"\n\n\n// Initializing from a Raw Value\nlet possiblePlanet = PlanetRaw(rawValue: 7)\n\nlet positionToFind = 11\nif let somePlanet = PlanetRaw(rawValue: positionToFind) {\n    switch somePlanet {\n    case .earth:\n        print(\"Mostly harmless\")\n    default:\n        print(\"Not a safe place for humans\")\n    }\n} else {\n    print(\"There isn't a planet at position \\(positionToFind)\")\n}\n\n\n// Recursive Enumerations\nenum ArithmeticExpression {\n    case number(Int)\n    indirect case addition(ArithmeticExpression, ArithmeticExpression)\n    indirect case multiplication(ArithmeticExpression, ArithmeticExpression)\n}\n\nindirect enum ArithmeticExpression2 {\n    case number(Int)\n    case addition(ArithmeticExpression2, ArithmeticExpression2)\n    case multiplication(ArithmeticExpression2, ArithmeticExpression2)\n}\n\nlet five = ArithmeticExpression.number(5)\nlet four = ArithmeticExpression.number(4)\nlet sum = ArithmeticExpression.addition(five, four)\nlet product = ArithmeticExpression.multiplication(sum, ArithmeticExpression.number(2))\n\nfunc evaluate(_ expression: ArithmeticExpression) -> Int {\n    switch expression {\n    case .number(let value):\n        return value\n    case let .addition(lhs, rhs):\n        return evaluate(lhs) + evaluate(rhs)\n    case let .multiplication(lhs, rhs):\n        return evaluate(lhs) * evaluate(rhs)\n    }\n}\n\nprint(evaluate(product))\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/08-Enumerations.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/09-ClassesAndStructures.playground/Contents.swift",
    "content": "// Classes and Structures\n\nclass SomeClasse {\n    \n}\n\nstruct SomeStruct {\n    \n}\n\nstruct Resolution {\n    var width = 0\n    var height = 0\n}\n\nclass VideoMode {\n    var resolution = Resolution()\n    var interlaced = false\n    var frameRate = 0.0\n    var name: String?\n}\n\n// Class and Structure Instances\nlet someResolution = Resolution()\nlet someVideoMode = VideoMode()\nprint(\"The width of someResolution is \\(someResolution.width)\")\nprint(\"The width of someVideoMode is \\(someVideoMode.resolution.width)\")\n\nsomeVideoMode.resolution.width = 1280\nprint(\"The width of someVideoMode is now \\(someVideoMode.resolution.width)\")\n\n// Memberwise Initializers for Structure Types\n//  All structures have an automatically-generated memberwise initializer, which you can use to initialize the member properties of new structure instances.\nlet vga = Resolution(width: 640, height: 480)\n\n\n// Structures and Enumerations are Value Types\n//  A value type is a type that is copied when it is assigned to a variable or constant, or when it is passed to a function.\nlet hd = Resolution(width: 1920, height: 1080)\nvar cinema = hd\ncinema.width = 2048\nprint(\"cinema is now \\(cinema.width) pixels wide\")\nprint(\"hd is still \\(hd.width) pixels wide\")\n\nenum CompassPoint {\n    case noth, south, east, west\n}\nvar currentDirection = CompassPoint.west\nlet rememberedDirection = currentDirection\ncurrentDirection = .east\nif rememberedDirection == .west {\n    print(\"The remembered direction is still .west\")\n}\n\n\n// Classes are Reference Types\n//  Reference types are not copied when they are assigned to a variable or constant, or when they are passed to a function. Rather than a copy, a reference to the same existing instance is used instead.\n\nlet tenEighty = VideoMode()\ntenEighty.resolution = hd\ntenEighty.interlaced = true\ntenEighty.name = \"1080i\"\ntenEighty.frameRate = 25.0\n\nlet alsoTenEighty = tenEighty\nalsoTenEighty.frameRate = 30.0\nprint(\"The frameRate property of tenEighty is now \\(tenEighty.frameRate)\")\n\n// Identity Operators\nif tenEighty === alsoTenEighty {\n    print(\"tenEighty and alsoTenEighty refer to the same VideoMode instance.\")\n}\n//  Note that “identical to” (represented by three equals signs, or ===) does not mean the same thing as “equal to” (represented by two equals signs, or ==):\n\n// Pointers\n// A Swift constant or variable that refers to an instance of some reference type is similar to a pointer in C, but is not a direct pointer to an address in memory.\n\n\n// Choosing Between Classes and Structures\n// Assignment and Copy Behaviour for Dictionaries\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/09-ClassesAndStructures.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/10-Properties.playground/Contents.swift",
    "content": "// Properties\n\n// Stored Properties\nstruct FixedLengthRange {\n    var firstValue: Int\n    let length: Int\n}\nvar rangeOfThreeItems = FixedLengthRange(firstValue: 0, length: 3)\nrangeOfThreeItems.firstValue = 6\n\n\n// Stored Properties of Constant Structure Instances\n//  If you create an instance of a structure and assign that instance to a constant, you cannot modify the instance’s properties, even if they were declared as variable properties:\nlet rangeOfFourItems = FixedLengthRange(firstValue: 0, length: 4)\n//rangeOfFourItems.firstValue = 6\n// The above line will report and error, even though firstValue is a variable property\n\n\n// Lazy Stored Properties\nclass DataImporter {\n    /*\n    DataImporter is a class to import data from an external file.\n    The class is assumed to take a non-trivial amount of time to initialize\n    */\n    var fileName = \"data.txt\"\n    // the Data Importer class would provide data importing functionality here\n}\n\nclass DataManager {\n    lazy var importer = DataImporter()\n    var data = [String]()\n    // the DataManager class would provide data management functionality here\n}\n\nlet manager = DataManager()\nmanager.data += [\"Some data\"]\nmanager.data += [\"Some more data\"]\n// the DataImporter instance for the importer property has not yet been created\nprint(manager.importer.fileName)\n// the DataImporter instance for the importer property has now been created\n\n\n// Computed Properties\nstruct Point {\n    var x = 0.0, y = 0.0\n}\nstruct Size {\n    var width = 0.0, height = 0.0\n}\nstruct Rect {\n    var origin = Point()\n    var size = Size()\n    var center: Point {\n    get {\n        let centerX = origin.x + (size.width / 2)\n        let centerY = origin.y + (size.height / 2)\n        return Point(x: centerX, y: centerY)\n    }\n    set(newCenter) {\n        origin.x = newCenter.x - (size.width / 2)\n        origin.y = newCenter.y - (size.height / 2)\n    }\n    }\n}\nvar square = Rect(origin: Point(x: 0.0, y: 0.0), size: Size(width: 10.0, height: 10.0))\nlet initialSquareCenter = square.center\nsquare.center = Point(x: 15.0, y: 15.0)\nprint(\"square.origin is now at (\\(square.origin.x), \\(square.origin.y))\")\n\n// Shorthand Setter Declaration\n// If no name is given for the new value a variable of name newValue is autogenerated\nstruct AlternativeRect {\n    var origin = Point()\n    var size = Size()\n    var center: Point {\n    get {\n        let centerX = origin.x + (size.width / 2)\n        let centerY = origin.y + (size.height / 2)\n        return Point(x: centerX, y: centerY)\n    }\n    set {\n        origin.x = newValue.x - (size.width / 2)\n        origin.y = newValue.y - (size.height / 2)\n    }\n    }\n}\n\n// Read only Computed Properties\nstruct Cuboid {\n    var width = 0.0, height = 0.0, depth = 0.0\n    var volume: Double {\n    return width * height * depth\n    }\n}\nlet fourByFiveByTwo = Cuboid(width: 4.0, height: 5.0, depth: 2.0)\nprint(\"the volume of fourByFiveByTwo is \\(fourByFiveByTwo.volume)\")\n\n\n// Property Observers\nclass StepCounter {\n    var totalSteps: Int = 0 {\n    willSet(newTotalSteps) {\n        print(\"About to set totalSteps to \\(newTotalSteps)\")\n    }\n    didSet {\n        if totalSteps > oldValue {\n            print(\"Added \\(totalSteps - oldValue) steps\")\n        }\n    }\n    }\n}\nlet stepCounter = StepCounter()\nstepCounter.totalSteps = 200\nstepCounter.totalSteps = 360\nstepCounter.totalSteps = 896\n\n\n// Type Properties\n//  Type properties are useful for defining values that are universal to all instances of a particular type, such as a constant property that all instances can use (like a static constant in C), or a variable property that stores a value that is global to all instances of that type (like a static variable in C).\n\n// Type Property Syntax\nstruct SomeStructure {\n    static var storedTypeProperty = \"Some value.\"\n    static var computedTypeProperty: Int {\n        return 1\n    }\n}\n\nenum SomeEnumeration {\n    static var storedTypeProperty = \"Some value.\"\n    static var computedTypeProperty: Int {\n        return 6\n    }\n}\n\nclass SomeClass {\n    static var storedTypeProperty = \"Some value.\"\n    static var computedTypeProperty: Int {\n        return 27\n    }\n    class var overrideableComputedTypeProperty: Int {\n        return 107\n    }\n}\n\n// Querying and setting Type Properties\nprint(SomeStructure.storedTypeProperty)             // prints \"Some value.\"\nSomeStructure.storedTypeProperty = \"Another value.\"\nprint(SomeStructure.storedTypeProperty)             // prints \"Another value.\"\nprint(SomeEnumeration.computedTypeProperty)         // prints \"6\"\nprint(SomeClass.computedTypeProperty)               // prints \"27\"\n\nstruct AudioChannel {\n    static let thresholdLevel = 10\n    static var maxInputLevelForAllChannels = 0\n    var currentLevel: Int = 0 {\n        didSet {\n            if currentLevel > AudioChannel.thresholdLevel {\n                // cap the new audio level to the threshold level\n                currentLevel = AudioChannel.thresholdLevel\n            }\n            if currentLevel > AudioChannel.maxInputLevelForAllChannels {\n                // store this as the new overall maximum input level\n                AudioChannel.maxInputLevelForAllChannels = currentLevel\n            }\n        }\n    }\n}\nvar leftChannel = AudioChannel()\nvar rightChannel = AudioChannel()\nleftChannel.currentLevel = 7\nprint(leftChannel.currentLevel)\nprint(AudioChannel.maxInputLevelForAllChannels)\nrightChannel.currentLevel = 11\nprint(rightChannel.currentLevel)\nprint(AudioChannel.maxInputLevelForAllChannels)\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/10-Properties.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/11-Methods.playground/Contents.swift",
    "content": "// Methods Chapter\n\n// Instance Methods\nclass Counter {\n    var count = 0\n    func increment() {\n        count += 1\n    }\n    func increment(by amount: Int) {\n        count += amount\n    }\n    func reset() {\n        count = 0\n    }\n}\nlet counter = Counter()\ncounter.increment()\ncounter.increment(by:5)\ncounter.reset()\n\n\n// The self Property\n//  Every instance of a type has an implicit property called self, which is exactly equivalent to the instance itself. You use this implicit self property to refer to the current instance within its own instance methods.\nstruct Point {\n    var x = 0.0, y = 0.0\n    func isToTheRightOf(x: Double) -> Bool {\n        return self.x > x\n    }\n}\nlet somePoint = Point(x: 4.0, y: 5.0)\nif somePoint.isToTheRightOf(x: 1.0) {\n    print(\"This point is to the right of the line where x == 1.0\")\n}\n\n\n// Modifying Value TYpes from Within\n// Instance Methods\n//  if you need to modify the properties of your structure or enumeration within a particular method, you can opt in to mutating behavior for that method.\nstruct Point2 {\n    var x = 0.0, y = 0.0\n    mutating func moveBy(x deltaX: Double, y deltaY:Double) {\n        x += deltaX\n        y += deltaY\n    }\n}\nvar somePoint2 = Point2(x: 1.0, y: 1.0)\nsomePoint2.moveBy(x:2.0, y:3.0)\nprint(\"The point is now at (\\(somePoint2.x), \\(somePoint2.y))\")\n\nlet fixedPoint = Point2(x: 3.0, y: 3.0)\n//fixedPoint.moveByX(2.0, y: 3.0)\n// this will report an error because fixedPoint is a constant\n\n// Assigning to self Within a Mutating Method\nstruct Point3 {\n    var x = 0.0, y = 0.0\n    mutating func moveByX(deltaX: Double, y deltaY: Double) {\n        self = Point3(x: x + deltaX, y: y + deltaY)\n    }\n}\n\n//  Mutating methods for enumerations can set the implicit self parameter to be a different member from the same enumeration:\nenum TriStateSwitch {\n    case off, low, high\n    mutating func next() {\n        switch self {\n        case .off:\n            self = .low\n        case .low:\n            self = .high\n        case .high:\n            self = .off\n        }\n    }\n}\nvar ovenLight = TriStateSwitch.low\novenLight.next()\novenLight.next()\n\n\n// Type Methods\nclass SomeClass {\n    class func someTypeMethod() {\n        // type method implementation goes here\n    }\n}\nSomeClass.someTypeMethod()\n\nstruct LevelTracker {\n    static var highestUnlockedLevel = 1\n    var currentLevel = 1\n    \n    static func unlock(_ level: Int) {\n        if level > highestUnlockedLevel { highestUnlockedLevel = level }\n    }\n    \n    static func isUnlocked(_ level: Int) -> Bool {\n        return level <= highestUnlockedLevel\n    }\n    \n    @discardableResult\n    mutating func advance(to level: Int) -> Bool {\n        if LevelTracker.isUnlocked(level) {\n            currentLevel = level\n            return true\n        } else {\n            return false\n        }\n    }\n}\n\nclass Player {\n    var tracker = LevelTracker()\n    let playerName: String\n    func complete(level: Int) {\n        LevelTracker.unlock(level + 1)\n        tracker.advance(to: level + 1)\n    }\n    init(name: String) {\n        playerName = name\n    }\n}\n\nvar player = Player(name: \"Argyrios\")\nplayer.complete(level: 1)\nprint(\"highest unlocked level is now \\(LevelTracker.highestUnlockedLevel)\")\n\nplayer = Player(name: \"Beto\")\nif player.tracker.advance(to: 6) {\n    print(\"player is now on level 6\")\n} else {\n    print(\"level 6 has not yet been unlocked\")\n}\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/11-Methods.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/12-Subscripts.playground/Contents.swift",
    "content": "// Subscripts\n\n/*\nsubscript(index: Int) -> Int {\n    get {\n        // return an appropriate subscript value here\n    }\n    set(newValue) {\n        // perform a suitable setting action here\n    }\n}\n*/\n\nstruct TimesTable {\n    let multiplier: Int\n    subscript(index: Int) -> Int {\n        return multiplier * index\n    }\n}\nlet threeTimesTable = TimesTable(multiplier: 3)\nprint(\"six times three is \\(threeTimesTable[6])\")\n\n// Subscript Usage\nvar numberOfLegs = [\"spider\": 8, \"ant\": 6, \"cat\": 4]\nnumberOfLegs[\"bird\"] = 2\n\n// Subscript Options\nstruct Matrix {\n    let rows: Int, columns: Int\n    var grid: [Double]\n    init(rows: Int, columns: Int) {\n        self.rows = rows\n        self.columns = columns\n        grid = Array(repeating: 0.0, count: rows * columns)\n    }\n    func indexIsValid(row: Int, column: Int) -> Bool {\n        return row >= 0 && row < rows && column >= 0 && column < columns\n    }\n    subscript(row: Int, column: Int) -> Double {\n        get {\n            assert(indexIsValid(row: row, column: column), \"Index out of range\")\n            return grid[(row * columns) + column]\n        }\n        set {\n            assert(indexIsValid(row: row, column: column), \"Index out of range\")\n            grid[(row * columns) + column] = newValue\n        }\n    }\n}\nvar matrix = Matrix(rows: 2, columns: 2)\nmatrix[0, 1] = 1.5\nmatrix[1, 0] = 3.2\nmatrix\n\n//let someValue = matrix[2, 2]\n// Assertion triggered due to out of range access\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/12-Subscripts.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/13-Inheritance.playground/Contents.swift",
    "content": "// Inheritance\n\n// Base Class\nclass Vehicle {\n    var currentSpeed = 0.0\n    var description: String {\n        return \"traveling at \\(currentSpeed) miles per hour\"\n    }\n    func makeNoise() {\n        // do nothing - an arbitrary vehicle doesn't necessarily make a noise\n    }\n}\nlet someVehicle = Vehicle()\nprint(\"Vehicle: \\(someVehicle.description)\")\n\nclass Bicycle: Vehicle {\n    var hasBasket = false\n}\nlet bicycle = Bicycle()\nbicycle.hasBasket = true\n\nbicycle.currentSpeed = 15.0\nprint(\"Bicycle: \\(bicycle.description)\")\n\n\nclass Tandem: Bicycle {\n    var currentNumberOfPassengers = 0\n}\n\nlet tandem = Tandem()\ntandem.hasBasket = true\ntandem.currentNumberOfPassengers = 2\ntandem.currentSpeed = 22.0\nprint(\"Tandem: \\(tandem.description)\")\n\n\n// Overriding\n// Overriding methods\nclass Train: Vehicle {\n    override func makeNoise() {\n        print(\"Choo Choo\")\n    }\n}\nlet train = Train()\ntrain.makeNoise()\n\n//Overriding Properties\n\nclass Car: Vehicle {\n    var gear = 1\n    override var description: String {\n        return super.description + \" in gear \\(gear)\"\n    }\n}\nlet car = Car()\ncar.currentSpeed = 25.0\ncar.gear = 3\nprint(\"Car: \\(car.description)\")\n\n// Overriding Property Observers\nclass AutomaticCar: Car {\n    override var currentSpeed: Double {\n        didSet{\n            gear = Int(currentSpeed / 10.0) + 1\n        }\n    }\n}\nlet automatic = AutomaticCar()\nautomatic.currentSpeed = 35.0\nprint(\"AutomaticCar: \\(automatic.description)\")\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/13-Inheritance.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/14-Initialization.playground/Contents.swift",
    "content": "// Initialization\n\nstruct Fahrenheit {\n    var temperature: Double\n    init() {\n        temperature = 32.0\n    }\n}\nvar f = Fahrenheit()\nprint(\"The default temperature is \\(f.temperature)° Fahrenheit\")\n\n\n// Customizing Initialization\n// Initialization Parameters\nstruct Celsius {\n    var temperatureInCelsius: Double\n    init(fromFahrenheit fahrenheit: Double) {\n        temperatureInCelsius = (fahrenheit - 32) / 1.8\n    }\n    init(fromKelvin kelvin: Double) {\n        temperatureInCelsius = kelvin - 273.15\n    }\n}\nlet boilingPointOfWater = Celsius(fromFahrenheit: 212.0)\nlet freezingPointOfWater = Celsius(fromKelvin: 273.15)\n\n// Parameter names and Argument Labels\nstruct Color {\n    let red, green, blue: Double\n    init(red: Double, green: Double, blue: Double) {\n        self.red   = red\n        self.green = green\n        self.blue  = blue\n    }\n    init(white: Double) {\n        red     = white\n        green   = white\n        blue    = white\n    }\n}\nlet magenta = Color(red: 1.0, green: 0.0, blue: 1.0)\nlet halfGray = Color(white: 0.5)\n//let verGreen = Color(0.0, 1.0, 0.0)\n// Compile time error because external names for parameters were omitted\n\n// Initializer Parameters Without Argument Labels\nstruct Celsius2 {\n    var temperatureInCelsius: Double\n    init(fromFahrenheit fahrenheit: Double) {\n        temperatureInCelsius = (fahrenheit - 32) / 1.8\n    }\n    init(fromKelvin kelvin: Double) {\n        temperatureInCelsius = kelvin - 273.15\n    }\n    init(_ celsius: Double) {\n        temperatureInCelsius = celsius\n    }\n}\nlet bodyTemperature = Celsius2(37.0)\n\n\n// Optional Property Types\nclass SurveyQuestion {\n    var text: String\n    var response: String?\n    init(text: String) {\n        self.text = text\n    }\n    func ask() {\n        print(text)\n    }\n}\nlet cheeseQuestion = SurveyQuestion(text: \"Do you like cheese?\")\ncheeseQuestion.ask()\ncheeseQuestion.response = \"Yes, I do like cheese.\"\n\n\n// Assigning Constant Properties during Initialization\nclass SurveyQuestion2 {\n    let text: String\n    var response: String?\n    init(text: String) {\n        self.text = text\n    }\n    func ask() {\n        print(text)\n    }\n}\nlet beetsQuestion = SurveyQuestion2(text: \"How about beets?\")\nbeetsQuestion.ask()\nbeetsQuestion.response = \"I also like beets. (But not with cheese.)\"\n\n\n// Default Initializer\nclass ShoppingListItem {\n    var name: String?\n    var quantity = 1\n    var purchased = false\n}\nvar item = ShoppingListItem()\n\n\n// Memberwise Initializers for Structure Types\n// Because both stored properties have a default value, the Size structure automatically receives an init(width:height:) memberwise initializer, which you can use to initialize a new Size instance:\nstruct Size {\n    var width = 0.0, height = 0.0\n}\nlet twoByTwo = Size(width: 2.0, height: 2.0)\n\n\n// Initializer Delegation for Value Types\n//struct Size2 {\n//    var width = 0.0, height = 0.0\n//}\nstruct Point {\n    var x = 0.0, y = 0.0\n}\nstruct Rect {\n    var origin = Point()\n    var size = Size()\n    init() {}\n    init(origin: Point, size: Size) {\n        self.origin = origin\n        self.size = size\n    }\n    init(center: Point, size: Size) {\n        let originX = center.x - (size.width / 2)\n        let originY = center.y - (size.height / 2)\n        self.init(origin: Point(x: originX, y: originY), size: size)\n    }\n}\nlet basicRect = Rect()\nlet originRect = Rect(origin: Point(x: 2.0, y: 2.0), size: Size(width: 5.0, height: 5.0))\nlet centerRect = Rect(center: Point(x: 4.0, y: 4.0), size: Size(width: 3.0, height: 3.0))\n\n\n// Class Inheritance and Initialization\n// Rule 1\n//   Designated initializers must call a designated initializer from their immediate superclass\n// Rule 2\n//   Convenience initializers must call another initializer available in the same class\n// Rule 3\n//   Convenience initializers must ultimately end up calling a designated initializer\n// Designated initializers must always delegate up. Convenience initializers must always delegate across\n\n// Initialization is a 2 stage process. There are several safety checks that the compiler performs\n// Safety Check 1\n//   A deignated initializer must ensure that all of the properties introduced by its class are initialized before it delegates up to a superclass\n// Safety Check 2\n//   A designated initializer must delegate up to a superclass initializer before assigning a value to an inherited property. If it doesn't, the new value the designated initializer assigns will be overwritten by the superclass as part of its own initialization\n// Safety Check 3\n//   A convenience initializer must delegate to another initializer before assigning a value to any property (including properties defined by the same class). If it doesn't, the new value the convenience initializer assigns will be overwritten by its own class's designated initializer.\n// Safety Check 4\n//   An initializer cannot call any instance methods, read the values of any instance properties, or refer to self as a value until after the first phase of initialization is complete.\n\n// Two-Phase initialization\n// Phase 1\n// - A designated or convenience initializer is called on a class\n// - Memory for a new instance of that class is allocated. The memory is not yet initialized.\n// - A designated initializer for that class confirms that all stored properties introduced by that class have a value. The memory for these stored properties is now initialized.\n// - The designated initializer hands off to a superclass initializer to perform the same task for its own stored properties.\n// - This continues up the class inheritance chain until the top of the chain is reached.\n// - Once the top of the chain is reached, and the final class in the chain has ensured that all of its stored properties have a value, the instance's memory is considered to be fully initialized, and phase 1 is complete.\n//\n// Phase 2\n// - Working back down from the top of the chain, each designated initializer in the chain has the option to customize the instance further. Initializers are now able to access self and can modify its properties, call its instance methods, and so on.\n// - Finally, any convenience initializers in the chain have the option to customize the instance and to work with self.\n\n// Initializer Inheritance and Overriding\nclass Vehicle {\n    var numberOfWheels = 0\n    var description: String {\n        return \"\\(numberOfWheels) wheel(s)\"\n    }\n}\n\nlet vehicle = Vehicle()\nprint(\"Vehicle: \\(vehicle.description)\")\n\nclass Bicycle: Vehicle {\n    override init() {\n        super.init()\n        numberOfWheels = 2\n    }\n}\n\nlet bicycle = Bicycle()\nprint(\"Bicycle: \\(bicycle.description)\")\n\n\n// Automatic Initializers\n// Rule 1\n//   If your subclass doesn't define any designated initializers, it automatically inherits all of its superclass designated initializers\n// Rule 2\n//   If your subclass provides an implementaction of all of its superclass designated initializers- either by inheriting them as per rule 1, or by providing a custom implementation as part of its definitition- the it automatically inherits all of the superclass convenience initializers.\n\n\n// Designated and Convenience Initializers in Action\nclass Food {\n    var name: String\n    init(name: String) {\n        self.name = name\n    }\n    convenience init() {\n        self.init(name: \"[Unnamed]\")\n    }\n}\nlet namedMeat = Food(name: \"Bacon\")\nlet mysteryMeat = Food()\n\nclass RecipeIngredient: Food {\n    var quantity: Int\n    init(name: String, quantity: Int) {\n        self.quantity = quantity\n        super.init(name: name)\n    }\n    override convenience init(name: String) {\n        self.init(name: name, quantity: 1)\n    }\n}\n\nlet oneMysteryItem = RecipeIngredient()\nlet oneBacon = RecipeIngredient(name: \"Bacon\")\nlet sixEggs = RecipeIngredient(name: \"Eggs\", quantity: 6)\n\n//  In this example, the superclass for RecipeIngredient is Food, which has a single convenience initializer called init(). This initializer is therefore inherited by RecipeIngredient. The inherited version of init() functions in exactly the same way as the Food version, except that it delegates to the RecipeIngredient version of init(name: String) rather than the Food version.\n\n\nclass ShoppingListItem2: RecipeIngredient {\n    var purchased = false\n    var description: String {\n        var output = \"\\(quantity) x \\(name)\"\n        output += purchased ? \" √\" : \" ✘\"\n        return output\n    }\n}\n\n//  Because ShoppingListItem2 provides a default value for all of the properties it introduces and does not define any initializers itself, ShoppingListItem automatically inherits all of the designated and convenience initializers from its superclass. ShoppingListItem2(name: \"Eggs, quantity: 6),\nvar breakfastList = [\n    ShoppingListItem2(),\n    ShoppingListItem2(name: \"Bacon\"),\n    ShoppingListItem2(name: \"Eggs\", quantity: 6),\n]\nbreakfastList[0].name = \"Orange juice\"\nbreakfastList[0].purchased = true\nfor item in breakfastList {\n    print(item.description)\n}\n\n\n// Failable Initializers\n#if swift(>=3.1)\nlet wholeNumber: Double = 12345.0\nlet pi = 3.14159\n\nif let valueMaintained = Int(exactly: wholeNumber) {\n    print(\"\\(wholeNumber) conversion to int maintains value\")\n}\n\nlet valueChanged = Int(exactly: pi)\n\nif valueChanged == nil {\n    print(\"\\(pi) conversion to int does not maintain value\")\n}\n#endif\n\nstruct Animal {\n    let species: String\n    init?(species: String) {\n        if species.isEmpty { return nil }\n        self.species = species\n    }\n}\n\nlet someCreature = Animal(species: \"Giraffe\")\n// is of type Animal?, not Animal\n\nif let giraffe = someCreature {\n    print(\"An animal was initialized with a species of \\(giraffe.species)\")\n}\n\nlet anonymousCreature = Animal(species: \"\")\n\nif anonymousCreature == nil {\n    print(\"The anonymous creature could not be initialized\")\n}\n\n// Failable Initializers for Enumerations\n\nenum TemperatureUnit {\n    case Kelvin, Celsius, Fahrenheit\n    init?(symbol: Character) {\n        switch symbol {\n        case \"K\":\n            self = .Kelvin\n        case \"C\":\n            self = .Celsius\n        case \"F\":\n            self = .Fahrenheit\n        default:\n            return nil\n        }\n    }\n}\n\nlet fahrenheitUnit = TemperatureUnit(symbol: \"F\")\nif fahrenheitUnit != nil {\n    print(\"This is a defined temperature unit, so initialization succeeded.\")\n}\n\nlet unknownUnit = TemperatureUnit(symbol: \"X\")\nif unknownUnit == nil {\n    print(\"This is not a defined temperature unit, so initialization failed.\")\n}\n\n// Failable Initializers for Enumerations with Raw Values\nenum TempUnit: Character {\n    case Kelvin = \"K\", Celsius = \"C\", Fahrenheit = \"F\"\n}\n\nlet fahrUnit = TempUnit(rawValue:\"F\")\nif fahrUnit != nil {\n    print(\"This is a defined temperature unit, so initialization succeeded.\")\n}\n\nlet unknownUnit2 = TempUnit(rawValue: \"X\")\nif unknownUnit2 == nil {\n    print(\"This is not a defined temperature unit, so initialization failed.\")\n}\n\n// Propagation of Initialization Failure\n// Failable initializers for value types can trigger failure at any point. For classes, however a failable initializer can trigger an initialization failure only after all stored properties introduced by that class have been set to an initial value.\nclass Product {\n    let name: String!\n    init?(name: String) {\n        if name.isEmpty { return nil }\n        self.name = name\n    }\n}\n\nclass CartItem: Product {\n    let quantity: Int\n    init?(name: String, quantity: Int) {\n        if quantity < 1 { return nil }\n        self.quantity = quantity\n        super.init(name: name)\n    }\n}\n\nif let twoSocks = CartItem(name: \"sock\", quantity: 2) {\n    print(\"Item: \\(twoSocks.name), quantity: \\(twoSocks.quantity)\")\n}\n\nif let zeroShirts = CartItem(name: \"shirt\", quantity: 0) {\n    print(\"Item: \\(zeroShirts.name), quantity: \\(zeroShirts.quantity)\")\n} else {\n    print(\"Unable to initialize zero shirts\")\n}\n\nif let oneUnnamed = CartItem(name: \"\", quantity: 1) {\n    print(\"Item: \\(oneUnnamed.name), quantity: \\(oneUnnamed.quantity)\")\n} else {\n    print(\"Unable to initialize one unnamed product\")\n}\n\n\n// Overriding a Failable Initializer\nclass Document {\n    var name: String?\n    // this initializer creates a document with a nil name value\n    init() {}\n    // this initializer creates a document with a non-empty name value\n    init?(name: String) {\n        if name.isEmpty { return nil }\n        self.name = name\n    }\n}\n\nclass AutomaticallyNamedDocument: Document {\n    override init() {\n        super.init()\n        self.name = \"[Untitled]\"\n    }\n    override init(name: String) {\n        super.init()\n        if name.isEmpty {\n            self.name = \"[Untitled]\"\n        } else {\n            self.name = name\n        }\n    }\n}\n\nclass UntitledDocument: Document {\n    override init() {\n        super.init(name: \"[Untitled]\")!\n    }\n}\n\n\n// The init! Failable Initializer\n\n\n// Required Initializers\nclass SomeClass {\n    required init() {\n        // Initializer implementation goes here\n    }\n}\n\nclass SomeSubclass: SomeClass {\n    required init() {\n        // subclass implementation of the required initializer goes here\n    }\n}\n\n// Setting a default Property Value with a Closure or Function\nclass SomeOtherClass {\n    let someProperty: Int = {\n        // create a default value for someProperty inside this closure\n        // someValue must be of the same type as SomeType\n        return 1234\n        }()\n}\n//  Note that the closure’s end curly brace is followed by an empty pair of parentheses. This tells Swift to execute the closure immediately. If you omit these parentheses, you are trying to assign the closure itself to the property, and not the return value of the closure.\n\nstruct Chessboard {\n    let boardColors: [Bool] = {\n        var temporaryBoard = [Bool]()\n        var isBlack = false\n        for i in 1...8 {\n            for j in 1...8 {\n                temporaryBoard.append(isBlack)\n                isBlack = !isBlack\n            }\n            isBlack = !isBlack\n        }\n        return temporaryBoard\n    }()\n    func squareIsBlackAt(row: Int, column: Int) -> Bool {\n        return boardColors[(row * 8) + column]\n    }\n}\nlet board = Chessboard()\nprint(board.squareIsBlackAt(row: 0, column: 1))\nprint(board.squareIsBlackAt(row: 7, column: 7))\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/14-Initialization.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/15-Deinitialization.playground/Contents.swift",
    "content": "// Deinitialization Chapter\n\n//  Class definitions can have at most one deinitializer per class. The deinitializer does not take any parameters and is written without parentheses:\n\nstruct Bank {\n    static var coinsInBank = 10_000\n    static func distribute(coins numberOfCoinsRequested: Int) -> Int {\n        let numberOfCoinsToVend = min(numberOfCoinsRequested, coinsInBank)\n        coinsInBank -= numberOfCoinsToVend\n        return numberOfCoinsToVend\n    }\n    static func receive(coins: Int) {\n        coinsInBank += coins\n    }\n}\n\nclass Player {\n    var coinsInPurse: Int\n    init(coins: Int) {\n        coinsInPurse = Bank.distribute(coins: coins)\n    }\n    func win(coins: Int) {\n        coinsInPurse += Bank.distribute(coins: coins)\n    }\n    deinit {\n        Bank.receive(coins: coinsInPurse)\n    }\n}\nvar playerOne: Player? = Player(coins: 100)\nprint(\"A new player has joined the game with \\(playerOne!.coinsInPurse) coins\")\nprint(\"There are now \\(Bank.coinsInBank) coins left in the bank\")\n\nplayerOne!.win(coins: 2_000)\nprint(\"PlayerOne won 2000 coins & now has \\(playerOne!.coinsInPurse) coins\")\nprint(\"The bank now only has \\(Bank.coinsInBank) coins left\")\n\nplayerOne = nil\nprint(\"PlayerOne has left the game\")\nprint(\"The bank now has \\(Bank.coinsInBank) coins\")\nBank.coinsInBank // This should be back to 10_000. The playerOne variable doesn't get deinitialized in the playground because the GUI keeps it around in case it is referred to again I presume.\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/15-Deinitialization.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/16-AutomaticReferenceCounting.playground/Contents.swift",
    "content": "// Automatic Reference Counting\n\nclass Person {\n    let name: String\n    init(name: String) {\n        self.name = name\n        print(\"\\(name) is being initialized\")\n    }\n    deinit {\n        print(\"\\(name) is being deinitialized\")\n    }\n}\n\nvar reference1: Person?\nvar reference2: Person?\nvar reference3: Person?\n\nreference1 = Person(name: \"John Appleseed\")\nreference2 = reference1\nreference3 = reference1\n\nreference1 = nil\nreference2 = nil\nreference3 = nil\n// We should see the message that the Person object has been deinitialized however due to the playground this has not occured.\n\n// Strong Reference cycles between Classes\nclass Person2 {\n    let name: String\n    init(name: String) { self.name = name }\n    var apartment: Apartment?\n    deinit { print(\"\\(name) is being deinitialized\") }\n}\n\nclass Apartment {\n    let unit: String\n    init(unit: String) { self.unit = unit }\n    var tenant: Person2?\n    deinit { print(\"Apartment #\\(unit) is being deinitialized\") }\n}\n\nvar john: Person2?\nvar unit4A: Apartment?\n\njohn = Person2(name: \"John Appleseed\")\nunit4A = Apartment(unit: \"4A\")\n\njohn!.apartment = unit4A\nunit4A!.tenant = john\n\n//  Unfortunately, linking these two instances creates a strong reference cycle between them. The Person instance now has a strong reference to the Apartment instance, and the Apartment instance has a strong reference to the Person instance. Therefore, when you break the strong references held by the john and number73 variables, the reference counts do not drop to zero, and the instances are not deallocated by ARC:\n\njohn = nil\nunit4A = nil\n// We have now leaked memory\n\n// Resolving Strong Reference Cycles between Class Instances\n//  Use a weak reference whenever it is valid for that reference to become nil at some point during its lifetime. Conversely, use an unowned reference when you know that the reference will never be nil once it has been set during initialization.\n\n// Weak References\nclass Person3 {\n    let name: String\n    init(name: String) { self.name = name }\n    var apartment: Apartment3?\n    deinit { print(\"\\(name) is being deinitialized\") }\n}\n\nclass Apartment3 {\n    let unit: String\n    init(unit: String) { self.unit = unit }\n    weak var tenant: Person3?\n    deinit { print(\"Apartment #\\(unit) is being deinitialized\") }\n}\n\nvar james: Person3?\nvar number74: Apartment3?\n\njames = Person3(name: \"James Appleseed\")\nnumber74 = Apartment3(unit: \"74\")\n\njames!.apartment = number74\nnumber74!.tenant = james\n\njames = nil\nnumber74 = nil\n\n// Unowned References\nclass Customer {\n    let name: String\n    var card: CreditCard?\n    init(name: String) { self.name = name }\n    deinit { print(\"\\(name) is being deinitialized\") }\n}\n\nclass CreditCard {\n    let number: UInt64\n    unowned let customer: Customer\n    init(number: UInt64, customer: Customer) {\n        self.number = number\n        self.customer = customer\n    }\n    deinit { print(\"Card #\\(number) is being deinitialized\") }\n}\n\nvar justin: Customer?\njustin = Customer(name: \"Justin McIntyre\")\njustin!.card = CreditCard(number: 1234_5678_9012_3456, customer: justin!)\njustin = nil\n\n\n// Unowned References and Implicitly Unwrapped Optional Properties\n//  Both properties should always have a value, and neither property should ever be nil once initialization is complete. This enables both properties to be accessed directly (without optional unwrapping) once initialization is complete, while still avoiding a reference cycle.\n\nclass Country {\n    let name: String\n    var capitalCity: City!\n    init(name: String, capitalName: String) {\n        self.name = name\n        self.capitalCity = City(name: capitalName, country: self)\n    }\n}\n\nclass City {\n    let name: String\n    unowned let country: Country\n    init(name: String, country: Country) {\n        self.name = name\n        self.country = country\n    }\n}\n//  The initializer for City is called from within the initializer for Country. However, the initializer for Country cannot pass self to the City initializer until a new Country instance is fully initialized, as described in Two-Phase Initialization. To cope with this requirement, you declare the capitalCity property of Country as an implicitly unwrapped optional property, indicated by the exclamation mark at the end of its type annotation (City!). This means that the capitalCity property has a default value of nil, like any other optional, but can be accessed without the need to unwrap its value.\nvar country = Country(name: \"Canada\", capitalName: \"Ottawa\")\nprint(\"\\(country.name)'s capital city is called \\(country.capitalCity.name)\")\n\n\n// Strong Reference Cycles for Closures\nclass HTMLElement {\n    let name: String\n    let text: String?\n    lazy var asHTML: () -> String = {\n        if let text = self.text {\n            return \"<\\(self.name)>\\(text)</\\(self.name)>\"\n        } else {\n            return \"<\\(self.name) />\"\n        }\n    }\n    init(name: String, text: String? = nil) {\n        self.name = name\n        self.text = text\n    }\n    deinit {\n        print(\"\\(name) is being deinitialized\")\n    }\n}\n\nlet heading = HTMLElement(name: \"h1\")\nlet defaultText = \"some default text\"\nheading.asHTML = {\n    return \"<\\(heading.name)>\\(heading.text ?? defaultText)</\\(heading.name)>\"\n}\nprint(heading.asHTML())\n\n\nvar paragraph: HTMLElement? = HTMLElement(name: \"p\", text: \"hello, world\")\nprint(paragraph!.asHTML())\n//  Unfortunately, the HTMLElement class, as written above, creates a strong reference cycle between an HTMLElement instance and the closure used for its default asHTML value. \nparagraph = nil\n//  Note that the message in the HTMLElement deinitializer is not printed, which shows that the HTMLElement instance is not deallocated.\n\n// Resolving Strong Reference Cycles for Closures\n/*\n@lazy var someClosure: (Int, String) -> String = {\n    [unowned self] (index: Int, stringToProcess: String) -> String in\n    // Closure body goes here\n}\n*/\n\nclass HTMLElement2 {\n    let name: String\n    let text: String?\n    lazy var asHTML: () -> String = {\n        [unowned self] in\n        if let text = self.text {\n            return \"<\\(self.name)>\\(text)</\\(self.name)>\"\n        } else {\n            return \"<\\(self.name) />\"\n        }\n    }\n    init(name: String, text: String? = nil) {\n        self.name = name\n        self.text = text\n    }\n    deinit {\n        print(\"\\(name) is being deinitialized\")\n    }\n}\nvar paragraph2: HTMLElement2? = HTMLElement2(name: \"p\", text: \"hello, world\")\nprint(paragraph2!.asHTML())\n\nparagraph2 = nil\n// prints \"p is being deinitialized\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/16-AutomaticReferenceCounting.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/17-OptionalChaining.playground/Contents.swift",
    "content": "// Optional Chaining\n\nclass Person {\n    var residence: Residence?\n}\n\nclass Residence {\n    var numberOfRooms = 1\n}\n\nlet john = Person()\n//let roomCount = john.residence!.numberOfRooms\n// This triggers a runtime error\n\nif let roomCount = john.residence?.numberOfRooms {\n    print(\"John's residence has \\(roomCount) room(s).\")\n} else {\n    print(\"Unable to retreive the number of rooms.\")\n}\n\n// Defining Model Classes for Optional Chaining\nclass Person2 {\n    var residence: Residence2?\n}\n\nclass Residence2 {\n    var rooms = [Room]()\n    var numberOfRooms: Int {\n        return rooms.count\n    }\n    subscript(i: Int) -> Room {\n        return rooms[i]\n    }\n    func printNumberOfRooms() {\n        print(\"The number of rooms is \\(numberOfRooms)\")\n    }\n    var address: Address?\n}\n\nclass Room {\n    let name: String\n    init(name: String) { self.name = name }\n}\n\nclass Address {\n    var buildingName: String?\n    var buildingNumber: String?\n    var street: String?\n    func buildingIdentifier() -> String? {\n        if (buildingName != nil) {\n            return buildingName\n        } else if (buildingNumber != nil) {\n            return buildingNumber\n        } else {\n            return nil\n        }\n    }\n}\n\n\n// Accessing Properties Through Optional Chaining\nlet jack = Person2()\nif let roomCount = john.residence?.numberOfRooms {\n    print(\"John's residence has \\(roomCount) room(s).\")\n} else {\n    print(\"Unable to retreive the number of rooms.\")\n}\n\nlet someAddress = Address()\nsomeAddress.buildingNumber = \"29\"\nsomeAddress.street = \"Acacia Road\"\njack.residence?.address = someAddress\n\nfunc createAddress() -> Address {\n    print(\"Function was called.\")\n    \n    let someAddress = Address()\n    someAddress.buildingNumber = \"29\"\n    someAddress.street = \"Acacia Road\"\n    \n    return someAddress\n}\n\n// Calling Methods through Optional Chaining\nif jack.residence?.printNumberOfRooms() != nil {\n    print(\"It was possible to print the number of rooms.\")\n} else {\n    print(\"It was not possible to print the number of rooms.\")\n}\n// printNumberOfRooms returns Void? if called on an optional parent value\n\nif (jack.residence?.address = someAddress) != nil {\n    print(\"It was possible to set the address.\")\n} else {\n    print(\"It was not possible to set the address.\")\n}\n// Prints \"It was not possible to set the address.\"\n\n\n// Accessing Subscripts Through Optional Chaining\nif let firstRoomName = jack.residence?[0].name {\n    print(\"The first room name is \\(firstRoomName).\")\n} else {\n    print(\"Unable to retrieve the first room name.\")\n}\n\n//jack.residence?[0] = Room(name: \"Bathroom\")\n//This subscript setting attempt also fails, because residence is currently nil.\n\n\nlet jacksHouse = Residence2()\njacksHouse.rooms.append(Room(name: \"Living Room\"))\njacksHouse.rooms.append(Room(name: \"Kitchen\"))\njack.residence = jacksHouse\n\nif let firstRoomName = jack.residence?[0].name {\n    print(\"The first room name is \\(firstRoomName).\")\n} else {\n    print(\"Unable to retrieve the first room name.\")\n}\n\n// Accessing Subscripts of Optional Type\nvar testScores = [\"Dave\": [86, 82, 84], \"Bev\": [79, 94, 81]]\ntestScores[\"Dave\"]?[0] = 91\ntestScores[\"Bev\"]?[0] += 1\ntestScores[\"Brian\"]?[0] = 72 // Fails as no Brian\ntestScores\n\n\n// Linking Multiple levels of Chaining\nif let jacksStreet = jack.residence?.address?.street {\n    print(\"Jack's street name is \\(jacksStreet).\")\n} else {\n    print(\"Unable to retrieve the address.\")\n}\n\nlet jacksAddress = Address()\njacksAddress.buildingName = \"The Larches\"\njacksAddress.street = \"Laurel Street\"\njack.residence!.address = jacksAddress\n\nif let jacksStreet = jack.residence?.address?.street {\n    print(\"Jack's street name is \\(jacksStreet).\")\n} else {\n    print(\"Unable to retrieve the address.\")\n}\n\n\n// Chaining on Methods With Optional Return Values\nif let buildingIdentifier = jack.residence?.address?.buildingIdentifier() {\n    print(\"Jack's building identifier is \\(buildingIdentifier).\")\n}\n\nif let beginsWithThe = jack.residence?.address?.buildingIdentifier()?.hasPrefix(\"The\") {\n    if beginsWithThe {\n        print(\"Jack's building identifier begins with \\\"The\\\".\")\n    } else {\n        print(\"Jack's building identifier does not begin with \\\"The\\\".\")\n    }\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/17-OptionalChaining.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/18-ErrorHandling.playground/Contents.swift",
    "content": "import Cocoa\n\n//: # Error Handling\n//: Swift provides first-class support for throwing, catching, propagating, and manipulating recoverable errors at runtime (NOTE: recoverable).\n//:\n//: ## Representing and Throwing Errors\nenum VendingMachineError: Error {\n    case invalidSelection\n    case insufficientFunds(coinsNeeded: Int)\n    case outOfStock\n}\n\n// throw VendingMachineError.InsufficientFunds(required: 5)\n\n//: ## Handling Errors\n//: ### Propagating Errors using Throwing Functions\nfunc canThrowErrors() throws -> String { return \"\" }\nfunc cannotThrowErrors() -> String { return \"\" }\n\nstruct Item {\n    var price: Int\n    var count: Int\n}\n\nclass VendingMachine {\n    var inventory = [\n        \"Candy Bar\": Item(price: 12, count: 7),\n        \"Chips\": Item(price: 10, count: 4),\n        \"Pretzels\": Item(price: 7, count: 11)\n    ]\n    var coinsDeposited = 0\n    \n    func vend(itemNamed name: String) throws {\n        guard let item = inventory[name] else {\n            throw VendingMachineError.invalidSelection\n        }\n        \n        guard item.count > 0 else {\n            throw VendingMachineError.outOfStock\n        }\n        \n        guard item.price <= coinsDeposited else {\n            throw VendingMachineError.insufficientFunds(coinsNeeded: item.price - coinsDeposited)\n        }\n        \n        coinsDeposited -= item.price\n        \n        var newItem = item\n        newItem.count -= 1\n        inventory[name] = newItem\n        \n        print(\"Dispensing \\(name)\")\n    }\n}\n\n\nlet favoriteSnacks = [\n    \"Alice\": \"Chips\",\n    \"Bob\": \"Licorice\",\n    \"Eve\": \"Pretzels\",\n]\n\nfunc buyFavoriteSnack(person: String, vendingMachine: VendingMachine) throws {\n    let snackName = favoriteSnacks[person] ?? \"Candy Bar\"\n    try vendingMachine.vend(itemNamed: snackName)\n}\n//: Note that vend() must be marked with the try keyword. Also because the errors are not handled here the error is propagated up to buyFavoriteSnack() as noted by the throws keyword.\n\nstruct PurchasedSnack {\n    let name: String\n    init(name: String, vendingMachine: VendingMachine) throws {\n        try vendingMachine.vend(itemNamed: name)\n        self.name = name\n    }\n}\n\n//: ## Handling Errors Using Do-Catch\nvar vendingMachine = VendingMachine()\nvendingMachine.coinsDeposited = 8\n\ndo {\n    try buyFavoriteSnack(person: \"Alice\", vendingMachine: vendingMachine)\n    // Enjoy delicious snack\n} catch VendingMachineError.invalidSelection {\n    print(\"Invalid Selection\")\n} catch VendingMachineError.outOfStock {\n    print(\"Out of Stock\")\n} catch VendingMachineError.insufficientFunds(let coinsNeeded) {\n    print(\"Insufficient funds. Please insert an additional $\\(coinsNeeded).\")\n}\n\n//: ## Converting Errors to Optional Values\n//: If an error is thrown while evaluating the try? expression, the value of the expression is nil\nenum UnluckyError: Error { case unlucky }\nfunc someThrowingFunction() throws -> Int {\n    let success = arc4random_uniform(5)\n    if success == 0 { throw UnluckyError.unlucky }\n    return Int(success)\n}\n\nlet x = try? someThrowingFunction()\n\nlet y: Int?\ndo {\n    y = try someThrowingFunction()\n} catch {\n    y = nil\n}\n\n//: Try? lets you write concise error handling code when you want to handle all errors the same way.\n\nstruct Data { }\nfunc fetchDataFromDisk() throws -> Data {\n    let success = arc4random_uniform(5)\n    if success == 0 { throw UnluckyError.unlucky }\n    return Data()\n}\nfunc fetchDataFromServer() throws -> Data {\n    let success = arc4random_uniform(5)\n    if success == 0 { throw UnluckyError.unlucky }\n    return Data()\n}\n\nfunc fetchData() -> Data? {\n    if let data = try? fetchDataFromDisk() { return data }\n    if let data = try? fetchDataFromServer() { return data }\n    return nil\n}\nfetchData()\n\n\n//: ## Disabling Error Propagation\n//: Calling a throwing function or method with try! disables error propagation and wraps the call in a run-time assertion that no error will be thrown. If an error actually is thrown, you'll get a runtime error.\n\n//let photo = try! loadImage(\"./Resources/John Appleseed.jpg\")\n\n\n//: ## Specifying Clean-Up Actions\n//: A defer statement defers execution until the current scope is exited.\n//: Deferred statements may not contain any code that would transfer control out of the statements, such as a break or return statement, or by throwing an error.\n//: Deferred actions are executed in reverse order of how they are specified.\n\nenum FileError: Error {\n    case endOfFile\n    case fileClosed\n}\n\nfunc exists(_ filename: String) -> Bool { return true }\nclass FakeFile {\n    var isOpen = false\n    var filename = \"\"\n    var lines = 100\n    func readline() throws -> String? {\n        if self.isOpen {\n            if lines > 0 {\n                lines -= 1\n                return \"line number \\(lines) of text\\n\"\n            } else {\n                throw FileError.endOfFile\n                //return nil\n            }\n        } else {\n            throw FileError.fileClosed\n        }\n    }\n}\n\nfunc open(fileNamed: String) -> FakeFile {\n    let file = FakeFile()\n    file.filename = fileNamed\n    file.isOpen = true\n    print(\"\\(file.filename) has been opened\")\n    return file\n}\n\nfunc close(file: FakeFile) {\n    file.isOpen = false\n    print(\"\\(file.filename) has been closed\")\n}\n\nfunc processFile(named: String) throws {\n    if exists(named) {\n        let file = open(fileNamed: named)\n        defer {\n            close(file: file)\n        }\n        while let line = try file.readline() {\n            // Work with the file\n            print(line)\n        }\n        // close(file) is called here, at the end of the scope.\n    }\n}\n\ndo {\n    try processFile(named: \"myFakeFile\")\n} catch FileError.endOfFile {\n    print(\"Reached the end of the file\")\n} catch FileError.fileClosed {\n    print(\"The file isn't open\")\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/18-ErrorHandling.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/19-TypeCasting.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/19-TypeCasting.playground/section-1.swift",
    "content": "// Type Casting\n\nclass MediaItem {\n    var name: String\n    init(name: String) {\n        self.name = name\n    }\n}\n\nclass Movie: MediaItem {\n    var director: String\n    init(name: String, director: String) {\n        self.director = director\n        super.init(name: name)\n    }\n}\n\nclass Song: MediaItem {\n    var artist: String\n    init(name: String, artist: String) {\n        self.artist = artist\n        super.init(name: name)\n    }\n}\n\n//  Swift’s type checker is able to deduce that Movie and Song have a common superclass of MediaItem, and so it infers a type of MediaItem[] for the library array:\nlet library = [\n    Movie(name: \"Casablanca\", director: \"Michael Curtiz\"),\n    Song(name: \"Blue Suede Shoes\", artist: \"ElvisPresley\"),\n    Movie(name: \"Citizen Kane\", director: \"Orson Welles\"),\n    Song(name: \"The One And Only\", artist: \"Chesney Hawkes\"),\n    Song(name: \"Never Gonna Give You Up\", artist: \"Rick Astley\")\n]\n\n//  The items stored in library are still Movie and Song instances behind the scenes. However, if you iterate over the contents of this array, the items you receive back are typed as MediaItem, and not as Movie or Song. In order to work with them as their native type, you need to check their type, or downcast them to a different type, as described below.\n// Checking Type\nvar movieCount = 0\nvar songCount = 0\n\nfor item in library {\n    if item is Movie {\n        movieCount += 1\n    } else if item is Song {\n        songCount += 1\n    }\n}\nprint(\"Media library contains \\(movieCount) movies and \\(songCount) songs\")\n\n\n// Downcasting\nfor item in library {\n    if let movie = item as? Movie {\n        print(\"Movie: '\\(movie.name)', dir. \\(movie.director)\")\n    } else if let song = item as? Song {\n        print(\"Song: '\\(song.name)', by \\(song.artist)\")\n    }\n}\n\n\n// Type Casting for Any and AnyObject\nvar things = [Any]()\n\nthings.append(0)\nthings.append(0.0)\nthings.append(42)\nthings.append(3.1459)\nthings.append(\"hello\")\nthings.append((3.0, 5.0))\nthings.append(Movie(name: \"Ghostbusters\", director: \"Ivan Reitman\"))\nthings.append({ (name: String) -> String in \"Hello, \\(name)\" })\n\nfor thing in things {\n    switch thing {\n    case 0 as Int:\n        print(\"zero as an Int\")\n    case 0 as Double:\n        print(\"zero as a Double\")\n    case let someInt as Int:\n        print(\"an integer value of \\(someInt)\")\n    case let someDouble as Double where someDouble > 0:\n        print(\"a positive double value of \\(someDouble)\")\n    case is Double:\n        print(\"some other double value that I don't want to print\")\n    case let someString as String:\n        print(\"a string value of \\\"\\(someString)\\\"\")\n    case let (x, y) as (Double, Double):\n        print(\"an (x, y) point at \\(x), \\(y)\")\n    case let movie as Movie:\n        print(\"a movie called '\\(movie.name)', dir. \\(movie.director)\")\n    default:\n        print(\"something else\")\n    }\n}\n//  The cases of a switch statement use the forced version of the type cast operator (as, not as?) to check and cast to a specific type. This check is always safe within the context of a switch case statement.\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/20-NestedTypes.playground/Contents.swift",
    "content": "// Nested Types\n\nstruct BlackjackCard {\n    \n    // nested Suit enumeration\n    enum Suit: Character {\n        case spades = \"♠\", hearts = \"♡\", diamonds = \"♢\", clubs = \"♣\"\n    }\n    \n    // nestedRank enumeration\n    enum Rank: Int {\n        case two = 2, three, four, five, six, seven, eight, nine, ten\n        case jack, queen, king, ace\n        struct Values {\n            let first: Int, second: Int?\n        }\n        var values: Values {\n            switch self {\n            case .ace:\n                return Values(first: 1, second: 11)\n            case .jack, .queen, .king:\n                return Values(first: 10, second: nil)\n            default:\n                return Values(first: self.rawValue, second: nil)\n            }\n        }\n    }\n    \n    // BlackjackCard properties and methods\n    let rank: Rank, suit: Suit\n    var description: String {\n        var output = \"suit is \\(suit.rawValue),\"\n        output += \" value is \\(rank.values.first)\"\n        if let second = rank.values.second {\n            output += \" or \\(second)\"\n        }\n        return output\n    }\n}\n\nlet theAceOfSpades = BlackjackCard(rank: .ace, suit: .spades)\nprint(\"theAceOfSpades: \\(theAceOfSpades.description)\")\n\n\n// Referring to Nested Types\nlet heartsSymbol = BlackjackCard.Suit.hearts.rawValue\nprint(\"heartsSymbol is \\(heartsSymbol)\")\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/20-NestedTypes.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/21-Extensions.playground/Contents.swift",
    "content": "// Extensions\n\n/*\nextension SomeType {\n    // new functionality to add to SomeType goes here\n}\n\nextension SomeType: SomeProtocol, AnotherProtocol {\n    // implementation of protocol requirements goes here\n}\n*/\n\n// Computed Properties\nextension Double {\n    var km: Double { return self * 1_000.0 }\n    var m: Double { return self }\n    var cm: Double { return self / 100.0 }\n    var mm: Double { return self / 1_000.0 }\n    var ft: Double { return self / 3.28084 }\n}\nlet oneInch = 25.4.mm\nprint(\"One inch is \\(oneInch) meters\")\n\nlet threeFeet = 3.ft\nprint(\"Three feet is \\(threeFeet) meters\")\n\nlet aMarathon = 42.km + 195.m\nprint(\"A marathon is \\(aMarathon) meters long\")\n//  Extensions can add new computed properties, but they cannot add stored properties, or add property observers to existing properties.\n\n\n// Initializers\nstruct Size {\n    var width = 0.0, height = 0.0\n}\nstruct Point {\n    var x = 0.0, y = 0.0\n}\nstruct Rect {\n    var origin = Point()\n    var size = Size()\n}\nlet defaultRect = Rect()\nlet memberwiseRect = Rect(origin: Point(x: 2.0, y:2.0), size: Size(width: 5.0, height: 5.0))\n\nextension Rect {\n    init(center: Point, size: Size) {\n        let originX = center.x - (size.width / 2)\n        let originY = center.y - (size.height / 2)\n        self.init(origin: Point(x: originX, y: originY), size: size)\n    }\n}\nlet centerRect = Rect(center: Point(x: 4.0, y: 4.0), size: Size(width: 3.0, height:3.0))\n\n\n// Methods\nextension Int {\n    func repetitions(task: () -> Void) {\n        for _ in 0..<self {\n            task()\n        }\n    }\n}\n\n3.repetitions {\n    print(\"Hello!\")\n}\n\n\n// Mutating Instance Methods\nextension Int {\n    mutating func square() {\n        self = self * self\n    }\n}\n\nvar someInt = 3\nsomeInt.square()\nsomeInt\n\n\n// Subscripts\n// This example adds an integer subscript to Swift’s built-in Int type. This subscript [n] returns the decimal digit n places in from the right of the number:\nextension Int {\n    subscript(digitIndex: Int) -> Int {\n        var decimalBase = 1\n        for _ in 0..<digitIndex {\n            decimalBase *= 10\n        }\n        return (self / decimalBase) % 10\n    }\n}\n\n746381295[0]\n746381295[1]\n746381295[2]\n746381295[8]\n\n// If the Int value does not have enough digits for the requested index, the subscript implementation returns 0, as if the number had been padded with zeros to the left:\n\n746381295[9]\n\n\n// Nested Types\nextension Int {\n    enum Kind {\n        case negative, zero, positive\n    }\n    \n    var kind: Kind {\n        switch self {\n        case 0:\n            return .zero\n        case let x where x > 0:\n            return .positive\n        default:\n            return .negative\n        }\n    }\n}\n\n\nfunc printIntegerKinds(_ numbers: [Int]) {\n    for number in numbers {\n        switch number.kind {\n        case .negative:\n            print(\"-\")\n            //print(\"- \", terminator: false)\n        case .zero:\n            print(\"0\")\n            //print(\"0 \", terminator: false)\n        case .positive:\n            print(\"+\")\n            //print(\"+ \", terminator: false)\n        }\n    }\n    print(\"\")\n}\nprintIntegerKinds([3, 19, -27, 0, -6, 0, 7])\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/21-Extensions.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/22-Protocols.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='4.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/22-Protocols.playground/section-1.swift",
    "content": "// Protocols\n\nimport Foundation\n/*\nprotocol SomeProtocol {\n    // protocol definition goes here\n}\n\nstruct SomeStructure: FirstProtocol, AnotherProtocol {\n    // structure definition goes here\n}\n\n//  If a class has a superclass, list the superclass name before any protocols it adopts, followed by a comma:\n\nclass SomeClass: SomeSuperclass, FirstProtocol, AnotherProtocol {\n    // class definition goes here\n}\n*/\n\n\n// Property Requirements\n//  Property requirements are always declared as variable properties, prefixed with the var keyword.\n\nprotocol SomeProtocol {\n    var mustBeSettable: Int { get set }\n    var doesNotNeedToBeSettable: Int { get }\n}\n\n//  Always prefix type property requirements with the static keyword when you define them in a protocol. This is true even though type property requirements can be prefixed with the static or class keyword when implemented by a class:\n\nprotocol AnotherProtocol {\n    static var someTypeProperty: Int { get set }\n}\n\n// Here's an example of a protocol with a single instance property requirement:\nprotocol FullyNamed {\n    var fullName: String { get }\n}\n\nstruct Person: FullyNamed {\n    var fullName: String\n}\nlet john = Person(fullName: \"John AppleSeed\")\n\nclass Starship: FullyNamed {\n    var prefix: String?\n    var name: String\n    init(name: String, prefix: String? = nil) {\n        self.name = name\n        self.prefix = prefix\n    }\n    var fullName: String {\n        return ((prefix != nil ? prefix! + \" \" : \"\") + name)\n    }\n}\nvar ncc1701 = Starship(name: \"Enterprise\", prefix: \"USS\")\n\n\n// Method Requirements\n/*\nprotocol SomeProtocol {\n    static func someTypeMethod()\n}\n*/\n\nprotocol RandomNumberGenerator {\n    func random() -> Double\n}\n\n// linear congruential generator:\nclass LinearCongruentialGenerator: RandomNumberGenerator {\n    var lastRandom = 42.0\n    let m = 139968.0\n    let a = 3877.0\n    let c = 29573.0\n    func random() -> Double {\n        lastRandom = ((lastRandom * a + c).truncatingRemainder(dividingBy:m))\n        return lastRandom / m\n    }\n}\nlet generator = LinearCongruentialGenerator()\nprint(\"Here's a random number: \\(generator.random())\")\nprint(\"And another one: \\(generator.random())\")\n\n\n// Mutating Method Requirements\nprotocol Togglable {\n    mutating func toggle()\n}\n\nenum OnOffSwitch: Togglable {\n    case off, on\n    mutating func toggle() {\n        switch self {\n        case .off:\n            self = .on\n        case .on:\n            self = .off\n        }\n    }\n}\nvar lightSwitch = OnOffSwitch.off\nlightSwitch.toggle()\nlightSwitch\n\n\n// Initializer Requirements\n// Protocols can require specific initializers to be implemented by conforming types.\n/*\nprotocol SomeProtocol {\n    init(someParameter: Int)\n}\n*/\n\n// Class Implementations of Protocol Initializer Requirements\n// You can implement a protocol initializer requirement on a conforming class as either a designated initializer or a convenience initializer. In both cases, you must mark the initializer implementation with the required modifier\n/*\nclass SomeClass: SomeProtocol {\n    required init(someParameter: Int) {\n        // initializer implementation goes here\n    }\n{\n*/\n\n// If a subclass overrides a designated initializer from a superclass, and also implements a matching initializer requirement from a protocol, mark the initializer implementation with both the required and override modifiers\n/*\nprotocol SomeProtocol {\n    init()\n}\n\nclass SomeSuperClass {\n    init() {\n        // initializer implementation goes here\n    }\n}\n\nclass SomeSubClass: SomeSuperClass, SomeProtocol {\n    // \"required\" from SomeProtocol conformance; \"override\" from SomeSuperClass\n    required override init() {\n        // initializer implementation goes here\n    }\n}\n*/\n\n// Failable Initializer Requirements\n\n\n\n// Protocols as Types\n//  Protocols do not actually implement any functionality themselves. Nonetheless, any protocol you create will become a fully-fledged type for use\nclass Dice {\n    let sides: Int\n    let generator: RandomNumberGenerator\n    init(sides: Int, generator: RandomNumberGenerator) {\n        self.sides = sides\n        self.generator = generator\n    }\n    func roll() -> Int {\n        return Int(generator.random() * Double(sides)) + 1\n    }\n}\nvar d6 = Dice(sides: 6, generator: LinearCongruentialGenerator())\nfor _ in 1...5 {\n    print(\"Random dice roll is \\(d6.roll())\")\n}\n\n\n// Delegation\nprotocol DiceGame {\n    var dice: Dice { get }\n    func play()\n}\nprotocol DiceGameDelegate {\n    func gameDidStart(_ game: DiceGame)\n    func game(_ game: DiceGame, didStartNewTurnWithDiceRoll diceRoll: Int)\n    func gameDidEnd(_ game: DiceGame)\n}\n\nclass SnakesAndLadders: DiceGame {\n    let finalSquare = 25\n    let dice = Dice(sides: 6, generator:LinearCongruentialGenerator())\n    var square = 0\n    var board: [Int]\n    init() {\n        board = [Int](repeating: 0, count: finalSquare + 1)\n        board[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02\n        board[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08\n    }\n    var delegate: DiceGameDelegate?\n    func play() {\n        square = 0\n        delegate?.gameDidStart(self)\n        gameLoop: while square != finalSquare {\n            let diceRoll = dice.roll()\n            delegate?.game(self, didStartNewTurnWithDiceRoll: diceRoll)\n            switch square + diceRoll {\n            case finalSquare:\n                break gameLoop\n            case let newSquare where newSquare > finalSquare:\n                continue gameLoop\n            default:\n                square += diceRoll\n                square += board[square]\n            }\n        }\n        delegate?.gameDidEnd(self)\n    }\n}\n\nclass DiceGameTracker: DiceGameDelegate {\n    var numberOfTurns = 0\n    func gameDidStart(_ game: DiceGame) {\n        numberOfTurns = 0\n        if game is SnakesAndLadders {\n            print(\"Started a new game of Snakes and Ladders\")\n        }\n        print(\"The game is using a \\(game.dice.sides)-sided dice\")\n    }\n    func game(_ game: DiceGame, didStartNewTurnWithDiceRoll diceRoll: Int) {\n        numberOfTurns += 1\n        print(\"Rolled a \\(diceRoll)\")\n    }\n    func gameDidEnd(_ game: DiceGame) {\n        print(\"The game lasted for \\(numberOfTurns) turns\")\n    }\n}\nlet tracker = DiceGameTracker()\nlet game = SnakesAndLadders()\ngame.delegate = tracker\ngame.play()\n\n\n// Adding Protocol Conformance with an Extension\nprotocol TextRepresentable {\n    var textualDescription: String { get }\n}\nextension Dice: TextRepresentable {\n    var textualDescription: String {\n        return \"A \\(sides)-sided dice\"\n    }\n}\nlet d12 = Dice(sides: 12, generator: LinearCongruentialGenerator())\nprint(d12.textualDescription)\nd6.textualDescription\n\nextension SnakesAndLadders: TextRepresentable {\n    var textualDescription: String {\n        return \"A game of Snakes and Ladders with \\(finalSquare) squares\"\n    }\n}\nprint(game.textualDescription)\n\n\n// Declaring Protocol Adoption with an Extension\n//  If a type already conforms to all of the requirements of a protocol, but has not yet stated that it adopts that protocol, you can make it adopt the protocol with an empty extension:\nstruct Hamster {\n    var name: String\n    var textualDescription: String {\n        return \"A hamster named \\(name)\"\n    }\n}\nextension Hamster: TextRepresentable {}\n\nlet simonTheHamster = Hamster(name: \"Simon\")\nlet somethingTextRepresentable: TextRepresentable = simonTheHamster\nprint(somethingTextRepresentable.textualDescription)\n\n\n// Collections of Protocol Types\nlet things: [TextRepresentable] = [game, d12, simonTheHamster]\nfor thing in things {\n    print(thing.textualDescription)\n}\n//  Note that the thing constant is of type TextRepresentable. It is not of type Dice, or DiceGame, or Hamster, even if the actual instance behind the scenes is of one of those types.\n\n\n// Protocol Inheritance\n/*\nprotocol InheritingProtocol: SomeProtocol, Another Protocol {\n    // protocol definition goes here\n}\n*/\n\nprotocol PrettyTextRepresentable: TextRepresentable {\n    var prettyTextualDescription: String { get }\n}\n//  PrettyTextRepresentable must satisfy all of the requirements enforced by TextRepresentable, plus the additional requirements enforced by PrettyTextRepresentable.\n\nextension SnakesAndLadders: PrettyTextRepresentable {\n    var prettyTextualDescription: String {\n        var output = textualDescription + \":\\n\"\n        for index in 1...finalSquare {\n            switch board[index] {\n            case let ladder where ladder > 0:\n                output += \"▲ \"\n            case let snake where snake < 0:\n                output += \"▼ \"\n            default:\n                output += \"○ \"\n            }\n        }\n        return output\n    }\n}\nprint(game.prettyTextualDescription)\n\n\n// Class-Only Protocols\n// You can limit protocol adoption to class types by adding the class keyword.\n/*\nprotocol SomeClassOnlyProtocol: class, SomeInheritedProtocol {\n    // class-only protocol definition goes here\n}\n*/\n// Note: Use a class-only protocol when the behaviour defined by that protocol's requirements assumes or requires that a conforming type has reference semantics rather than value semantics.\n\n\n// Protocol Composition\nprotocol Named {\n    var name: String { get }\n}\nprotocol Aged {\n    var age: Int { get }\n}\nstruct Person2: Named, Aged {\n    var name: String\n    var age: Int\n}\nfunc wishHappyBirthday(to celebrator: Named & Aged) {\n    print(\"Happy birthday, \\(celebrator.name), you're \\(celebrator.age)!\")\n}\nlet birthdayPerson = Person2(name:\"Malcom\", age: 21)\nwishHappyBirthday(to: birthdayPerson)\n// Note: Protocol compositions do not define a new, permanent protocol type. Rather they define a temporary local protocol that has the combined requirements of all protocols in the composition.\n\n\n// Checking for Protocol Conformance\nprotocol HasArea {\n    var area: Double { get }\n}\n//  You can check for protocol conformance only if your protocol is marked with the @objc attribute\nclass Circle: HasArea {\n    let pi = 3.1415927\n    var radius: Double\n    var area: Double { return pi * radius * radius }\n    init(radius: Double) { self.radius = radius }\n}\nclass Country: HasArea {\n    var area: Double\n    init(area: Double) { self.area = area }\n}\n\nclass Animal {\n    var legs: Int\n    init(legs: Int) { self.legs = legs }\n}\n\nlet objects: [AnyObject] = [\n    Circle(radius: 2.0),\n    Country(area: 243_610),\n    Animal(legs: 4)\n]\nfor object in objects {\n    if let objectWithArea = object as? HasArea {\n        print(\"Area is \\(objectWithArea.area)\")\n    } else {\n        print(\"Something that doesn't have an area\")\n    }\n}\n//  Note that the underlying objects are not changed by the casting process. They continue to be a Circle, a Country and an Animal. However, at the point that they are stored in the objectWithArea constant, they are only known to be of type HasArea, and so only their area property can be accessed.\n\n\n// Optional Protocol Requirements\n//  Optional property requirements, and optional method requirements that return a value, will always return an optional value of the appropriate type when they are accessed or called, to reflect the fact that the optional requirement may not have been implemented.\n@objc protocol CounterDataSource {\n    @objc optional func increment(forCount count: Int) -> Int\n    @objc optional var fixedIncrement: Int { get }\n}\n\nclass Counter {\n    var count = 0\n    var dataSource: CounterDataSource?\n    func increment() {\n        if let amount = dataSource?.increment?(forCount: count) {\n            count += amount\n        } else if let amount = dataSource?.fixedIncrement {\n            count += amount\n        }\n    }\n}\n\nclass ThreeSource: NSObject, CounterDataSource {\n    let fixedIncrement = 3\n}\n\nvar counter = Counter()\ncounter.dataSource = ThreeSource()\nfor _ in 1...4 {\n    counter.increment()\n    print(counter.count)\n}\n\n@objc class TowardsZeroSource: NSObject, CounterDataSource {\n    func increment(forCount count: Int) -> Int {\n        if count == 0 {\n            return 0\n        } else if count < 0 {\n            return 1\n        } else {\n            return -1\n        }\n    }\n}\n\ncounter.count = -4\ncounter.dataSource = TowardsZeroSource()\nfor _ in 1...5 {\n    counter.increment()\n    print(counter.count)\n}\n\n\n// Protocol Extensions\n// Protocols can be extended to procide method and property implementations to conforming types. This allows you to define behaviour on protocols themselves, rather than in each type's individual conformance or in a global function.\n// For example, the RandomNumberGenerator protocol can be extended to provide a randomBool() method, which uses the result of the required random() method to return a random Bool value:\n\nextension RandomNumberGenerator {\n    func randomBool() -> Bool {\n        return random() > 0.5\n    }\n}\n\n// By creating an extension on the protocol, all conforming types automatically gain this method implementation without and additional modification.\n\n//let generator2 = LinearCongruentialGenerator()\n//print(\"Here's a random number: \\(generator2.random())\")\nprint(\"Here's a random Boolean: \\(generator.randomBool())\")\n\n\n// Providing Default Implementations\n// Protocol extensions can provide default implementations to any method or property requirement\n// If a conforming type provides its own implementation that is used instead.\n\nextension PrettyTextRepresentable {\n    var prettyTextualDescription: String {\n        return textualDescription\n    }\n}\n\nextension Hamster: PrettyTextRepresentable { }\nprint(simonTheHamster.prettyTextualDescription)\n\n\n// Adding Constraints to Protocol Extensions\n// You can specify constraints that conforming types must satisfy before methods and properties of an extension are available.\n// You use the where clause after the name of the protocol you are extending.\n\nextension Collection where Iterator.Element : TextRepresentable {\n    var textualDescription: String {\n        let itemsAsText = self.map { $0.textualDescription }\n        return \"[\" + itemsAsText.joined(separator: \", \") + \"]\"\n    }\n}\n\nlet murrayTheHamster = Hamster(name: \"Murray\")\nlet morganTheHamster = Hamster(name: \"Morgan\")\nlet mauriceTheHamster = Hamster(name: \"Maurice\")\nlet hamsters = [murrayTheHamster, morganTheHamster, mauriceTheHamster]\n\n// Because Array conforms to CollectionType, and the array's elements conform to the TextRepresentable protocol, the array can use the asList() method to get a textual representation of its contents:\n\nprint(hamsters.textualDescription)\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/23-Generics.playground/Contents.swift",
    "content": "// Generics\n\n// The Problem That Generics Solve\n//  standard, non-generic function\nfunc swapTwoInts(_ a: inout Int, _ b: inout Int) {\n    let temporaryA = a\n    a = b\n    b = temporaryA\n}\n\nvar someInt = 3\nvar anotherInt = 107\nswapTwoInts(&someInt, &anotherInt)\nprint(\"someInt is now \\(someInt), and anotherInt is now \\(anotherInt)\")\n\n//  The swapTwoInts function is useful, but it can only be used with Int values. If you want to swap two String values, or two Double values, you have to write more functions, such as the swapTwoStrings and swapTwoDoubles functions shown below\n\nfunc swapTwoStrings(_ a: inout String, _ b: inout String) {\n    let temporaryA = a\n    a = b\n    b = temporaryA\n}\n\nfunc swapTwoDoubles(_ a: inout Double, _ b: inout Double) {\n    let temporaryA = a\n    a = b\n    b = temporaryA\n}\n\n\n// Generic Functions\nfunc swapTwoValues<T>(_ a: inout T, _ b: inout T) {\n    let temporaryA = a\n    a = b\n    b = temporaryA\n}\n\nswapTwoValues(&someInt, &anotherInt)\nprint(\"someInt is now \\(someInt), and anotherInt is now \\(anotherInt)\")\n\nvar someString = \"hello\"\nvar anotherString = \"world\"\nswapTwoValues(&someString, &anotherString)\nprint(\"someString is now \\(someString), and anotherString is now \\(anotherString)\")\n\n\n// Generic Types\n// Non-generic version of a Stack first\nstruct IntStack {\n    var items = [Int]()\n    mutating func push(_ item: Int) {\n        items.append(item)\n    }\n    mutating func pop() -> Int {\n        return items.removeLast()\n    }\n}\n\n// Now a Generic version\nstruct Stack<Element> {\n    var items = [Element]()\n    mutating func push(_ item: Element) {\n        items.append(item)\n    }\n    mutating func pop() -> Element {\n        return items.removeLast()\n    }\n}\nvar stackOfStrings = Stack<String>()\nstackOfStrings.push(\"uno\")\nstackOfStrings.push(\"dos\")\nstackOfStrings.push(\"tres\")\nstackOfStrings.push(\"cuatro\")\nstackOfStrings\n\nlet fromTheTop = stackOfStrings.pop()\n\n// Extending a Generic Type\n\nextension Stack {\n    var topItem: Element? {\n        return items.isEmpty ? nil : items[items.count - 1]\n    }\n}\n\nif let topItem = stackOfStrings.topItem {\n    print(\"The top item on the stack is \\(topItem).\")\n}\n\n// Type Constraints\n/*\nfunc someFunction<T: SomeClass, U: SomeProtocol>(someT: T, someU: U) {\n    // function body goes here\n}\n*/\nfunc findIndex(ofString valueToFind: String, in array: [String]) -> Int? {\n    for (index, value) in array.enumerated() {\n        if value == valueToFind {\n            return index\n        }\n    }\n    return nil\n}\nlet strings = [\"cat\", \"dog\", \"llama\", \"parakeet\", \"terrapin\"]\nif let foundIndex = findIndex(ofString: \"llama\", in: strings) {\n    print(\"The index of llama is \\(foundIndex)\")\n}\n\nfunc findIndex<T:Equatable>(of valueToFind: T, in array: [T]) -> Int? {\n    for (index, value) in array.enumerated() {\n        if value == valueToFind {\n            return index\n        }\n    }\n    return nil\n}\nlet doubleIndex = findIndex(of: 9.3, in: [3.14159, 0.1, 0.25])\nlet stringIndex = findIndex(of: \"Andrea\", in: [\"Mike\", \"Malcolm\", \"Andrea\"])\n\n\n// Associated Types\nprotocol Container {\n    associatedtype Item\n    mutating func append(_ item: Item)\n    var count: Int { get }\n    subscript(i: Int) -> Item { get }\n}\n\nstruct IntStack2: Container {\n    // original IntStack implementation\n    var items = [Int]()\n    mutating func push(_ item: Int) {\n        items.append(item)\n    }\n    mutating func pop() -> Int {\n        return items.removeLast()\n    }\n    // conformance to the Container protocol\n    typealias Item = Int\n    mutating func append(_ item: Int) {\n        self.push(item)\n    }\n    var count: Int {\n        return items.count\n    }\n    subscript(i: Int) -> Int {\n        return items[i]\n    }\n}\n\nstruct Stack2<Element>: Container {\n    // original Stack<T> implementation\n    var items = [Element]()\n    mutating func push(_ item: Element) {\n        items.append(item)\n    }\n    mutating func pop() -> Element {\n        return items.removeLast()\n    }\n    // conformance to the Container protocol\n    mutating func append(_ item: Element) {\n        self.push(item)\n    }\n    var count: Int {\n        return items.count\n    }\n    subscript(i: Int) -> Element {\n        return items[i]\n    }\n}\n\n\n// Extending an Existing Type to Specify an Associated Type\nextension Array: Container {}\n\n\n// Generic Where Clauses\nfunc allItemsMatch<C1: Container, C2: Container>\n    (_ someContainer: C1, _ anotherContainer: C2) -> Bool\n    where C1.Item == C2.Item, C1.Item: Equatable {\n    \n    // check that both containers contain the same number of items\n    if someContainer.count != anotherContainer.count {\n        return false\n    }\n    \n    // check each pair of items it see if they are equivilent\n    for i in 0..<someContainer.count {\n        if someContainer[i] != anotherContainer[i] {\n            return false\n        }\n    }\n    \n    // all items match, so return true\n    return true\n}\nvar stackOfStrings2 = Stack2<String>()\nstackOfStrings2.push(\"uno\")\nstackOfStrings2.push(\"dos\")\nstackOfStrings2.push(\"tres\")\n\nvar arrayOfStrings = [\"uno\", \"dos\", \"tres\"]\n\nif allItemsMatch(stackOfStrings2, arrayOfStrings) {\n    print(\"All items match.\")\n} else {\n    print(\"Not all items match.\")\n}\n\n\n// Extensions with a Generic Where Clause\nextension Stack2 where Element: Equatable {\n    func isTop(_ item: Element) -> Bool {\n        guard let topItem = items.last else {\n            return false\n        }\n        return topItem == item\n    }\n}\n\nif stackOfStrings2.isTop(\"tres\") {\n    print(\"Top element is tres.\")\n} else {\n    print(\"Top element is something else.\")\n}\n\n// If you try to call the isTop(_:) method on a stack whose elements aren't equatable, you'll get a compile-time error.\nstruct NotEquatable { }\nvar notEquatableStack = Stack2<NotEquatable>()\nlet notEquatableValue = NotEquatable()\nnotEquatableStack.push(notEquatableValue)\n// notEquatableStack.isTop(notEquatableValue) // Error\n\nextension Container where Item: Equatable {\n    func startsWith(_ item: Item) -> Bool {\n        return count >= 1 && self[0] == item\n    }\n}\n\nif [9, 9, 9].startsWith(42) {\n    print(\"Starts with 42.\")\n} else {\n    print(\"Starts with something else.\")\n}\n\nextension Container where Item == Double {\n    func average() -> Double {\n        var sum = 0.0\n        for index in 0..<count {\n            sum += self[index]\n        }\n        return sum / Double(count)\n    }\n}\nprint([1260.0, 1200.0, 98.6, 37.0].average())\n\n\n// Associated Types with a Generic Where Clause\nprotocol Container2 {\n    associatedtype Item\n    mutating func append(_ item: Item)\n    var count: Int { get }\n    subscript(i: Int) -> Item { get }\n    \n    associatedtype Iterator: IteratorProtocol where Iterator.Element == Item\n    func makeIterator() -> Iterator\n}\n\nprotocol ComparableContainer: Container where Item: Comparable { }\n\n// Generic Subscripts\nextension Container {\n    subscript<Indices: Sequence>(indices: Indices) -> [Item]\n        where Indices.Iterator.Element == Int {\n            var result = [Item]()\n            for index in indices {\n                result.append(self[index])\n            }\n            return result\n    }\n}\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/23-Generics.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/24-AccessControl.playground/Contents.swift",
    "content": "// Access Control\n\n//  You can assign specific access levels to individual types (classes, structures, and enumerations), as well as to properties, methods, initializers, and subscripts belonging to those types. Protocols can be restricted to a certain context, as can global constants, variables, and functions.\n\n\n// Modules and Source Files\n// A module is a single unit of code distribution - a framework or application. Something that can be imported\n\n\n// Access Levels\n// Public   - Available anywhere. Used for defining the public interface.\n// Internal - Use within any source file within a module.\n// Private  - Use only within the defining source file\n\n\n// No entity can be defined in terms of another entity that has a lower (more restrictive) access level.\n\n\n// Default Access level - Internal\n\n\n// Access Control Syntax\npublic class SomePublicClass {}\ninternal class SomeInternalClass {}\nfileprivate class SomeFilePrivateClass {}\nprivate class SomePrivateClass {}\n\npublic var somePublicVariable = 0\ninternal let someInternalConstant = 0\nfileprivate func someFilePrivateFunction() {}\nprivate func somePriviateFunction() {}\n\nclass SomeImplicitlyInternalClass {}        // implicitly internal\nlet someImplicitlyInternalConstant = 0      // implicitly internal\n\n\npublic class AnotherPublicClass {           // explicitly public class\n    public var somePublicProperty = 0       // explicitly public class member\n    var someInternalProperty = 0            // implicitly internal class member\n    private func somePrivateMethod() {}     // explicitly private class member\n}\n\nclass AnotherInternalClass {                // implicitly internal class\n    var someInternalProperty = 0            // implicitly internal class member\n    private func somePrivateMethod() {}     // explicitly private class member\n}\n\nfileprivate class AnotherFilePrivateClass { // explicitly file-private class\n    func someFilePrivateMethod() {}         // inplicitly file-private method\n    private func somePrivateMethod() {}     // explicitly file-private method\n}\n\nprivate class AnotherPrivateClass {         // explicitly private class\n    var somePrivateProperty = 0             // implicitly private class member\n    func somePrivateMethod() {}             // implicitly private class member\n}\n\n\n// Tuple Types\n//  Tuples don't have a way to explicitly set their access level. Instead the tuples access level is set from the most restrictive access level of its components\n\n\n// Function Types\n//  The access level of a function is set as the most restrictive access level of the function arguments and return type. You also must explicitly set the access level of the function type if it doesn't match the default\n/*\nfunc someFunction() -> (SomeInternalClass, SomePrivateClass) {\n    // function implementation goes here\n}\n\nThe function above won't compile because the SomePrivateClass sets the function type to private which is not explicitly set.\n*/\nprivate func someFunction() -> (SomeInternalClass, SomePrivateClass) {\n    // function implementation goes here\n    return (SomeInternalClass(), SomePrivateClass())\n}\n\n\n// Enumeration Types\n// The individual cases of an enumeration have the same access level as the enum\nprivate enum CompassPoint {\n    case north\n    case south\n    case east\n    case west\n}\n\n\n\n// Subclasses\n// A subclass cannot have a higher access level than its superclass.\n// An override can make an inherited class member more accessible than its superclass.\npublic class A {\n    fileprivate func someMethod() {}\n}\n\ninternal class B: A {\n    override internal func someMethod() {}\n}\n\npublic class C {\n    fileprivate func someMethod() {}\n}\ninternal class D: C {\n    override internal func someMethod() {\n        super.someMethod()\n    }\n}\n\n\n// Constants, Variables, Properties and Subscripts\n// A constant, variable or property cannot be more public than its type.\nprivate var privateInstance = SomePrivateClass()\n\n// Getters and Setters\n// Below, we have a value string that is internal. We also have a numberOfEdits variable that tracks how many times value has been modified. numberOfEdits is effectively readonly from outside the class because its setter is marked as private.\nstruct TrackedString {\n    private(set) var numberOfEdits = 0\n    var value: String = \"\" {\n        didSet {\n            numberOfEdits += 1\n        }\n    }\n}\n\nvar stringToEdit = TrackedString()\nstringToEdit.value = \"This string will be tracked.\"\nstringToEdit.value += \" This edit will increment numberOfEdits.\"\nstringToEdit.value += \" So will this one.\"\nprint(\"The number of edits is \\(stringToEdit.numberOfEdits)\")\nstringToEdit.numberOfEdits\n\n\n// Initializers\n// Default initialisers are given the same access level as their type except that public types get given internal initializers. You can provide a public initializer if you need one.\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/24-AccessControl.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/25-AdvancedOperators.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='4.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/25-AdvancedOperators.playground/section-1.swift",
    "content": "// Advanced Operators\n\n//  Unlike arithmetic operators in C, arithmetic operators in Swift do not overflow by default. Overflow behavior is trapped and reported as an error. To opt in to overflow behavior, use Swift’s second set of arithmetic operators that overflow by default, such as the overflow addition operator (&+). All of these overflow operators begin with an ampersand (&).\n\n// Bitwise Operators\n// Bitwise NOT\nlet initialBits: UInt8 = 0b00001111\nlet invertedBits = ~initialBits\n\n// Bitwise AND\nlet firstSixBits: UInt8 = 0b11111100\nlet lastSixBits:  UInt8 = 0b00111111\nlet middleFourBits = firstSixBits & lastSixBits\n\n// Bitwise OR\nlet someBits: UInt8 = 0b10110010\nlet moreBits: UInt8 = 0b01011110\nlet combinedBits = someBits | moreBits\n\n// Bitwise XOR\nlet firstBits: UInt8 = 0b00010100\nlet otherBits: UInt8 = 0b00000101\nlet outputBits = firstBits ^ otherBits\n\n// Bitwise Left and Right Shift\nlet shiftBits: UInt8 = 4\nshiftBits << 1\nshiftBits << 2\nshiftBits << 5\nshiftBits << 6\nshiftBits >> 2\n\nlet pink: UInt32 = 0xCC6699\nlet redComponent = (pink & 0xFF0000) >> 16\nlet greenComponent = (pink & 0x00FF00) >> 8\nlet blueComponent = pink & 0x0000FF\n\nlet negativeBits: Int8 = -4\nnegativeBits << 1\nnegativeBits << 2\nnegativeBits << 5\nnegativeBits << 6\nnegativeBits >> 2\nnegativeBits >> 5 // Doesn't overflow\n\n\n// Overflow Operators\n//  Overflow addition (&+)\n//  Overflow subtraction (&-)\n//  Overflow multiplication (&*)\n\nvar potentialOverflow = Int16.max\n// potentialOverflow += 1 // This causes an error if it runs\n\nvar willOverflow = UInt8.max\nwillOverflow = willOverflow &+ 1\n\n// Value Underflow\nvar unsignedOverflow = UInt8.min\nunsignedOverflow = unsignedOverflow &+ 1\n\nunsignedOverflow = UInt8.min\nunsignedOverflow = unsignedOverflow &- 1\n\nvar signedOverflow = Int8.min\nsignedOverflow = signedOverflow &- 1\n\n\n// Precedence and Associativity\n//  Operator associativity defines how operators of the same precedence are grouped together (or associated)—either grouped from the left, or grouped from the right. Think of it as meaning “they associate with the expression to their left,” or “they associate with the expression to their right.\n2 + 3 * 4 % 5\n\n// * and % have a higher precedence than +. \n// * and & have the same precendence as each other but both associate to their left. Think of this as adding implicit parentheses around these parts of the expression, starting from their left: (This explanation seems arbitrary to me. Aparently more info in the Expressions chapter)\n\n\n// Operator Functions\n// Infix Operators\nstruct Vector2D {\n    var x = 0.0, y = 0.0\n}\nextension Vector2D {\n    static func + (left: Vector2D, right: Vector2D) -> Vector2D {\n        return Vector2D(x: left.x + right.x, y: left.y + right.y)\n    }\n}\nlet vector = Vector2D(x: 3.0, y: 1.0)\nlet anotherVector = Vector2D(x: 2.0, y:4.0)\nlet combinedVector = vector + anotherVector\n\n// Prefix and Postfix Operators\nextension Vector2D {\n    static prefix func - (vector: Vector2D) -> Vector2D {\n        return Vector2D(x: -vector.x, y: -vector.y)\n    }\n}\nlet positive = Vector2D(x: 3.0, y: 4.0)\nlet negative = -positive\nlet alsoPositive = -negative\n\n\n// Compound Assignment Operators\nextension Vector2D {\n    static func += (left: inout Vector2D, right: Vector2D) {\n        left = left + right\n    }\n}\nvar original = Vector2D(x: 1.0, y: 2.0)\nlet vectorToAdd = Vector2D(x: 3.0, y: 4.0)\noriginal += vectorToAdd\n\n//  It is not possible to overload the default assignment operator (=). Only the compound assignment operators can be overloaded. Similarly, the ternary conditional operator (a ? b : c) cannot be overloaded.\n\n\n// Equivalence Operators\n//  Custom classes and structures do not receive a default implementation of the equivalence operators, known as the “equal to” operator (==) and “not equal to” operator (!=).\nextension Vector2D {\n    static func == (left: Vector2D, right: Vector2D) -> Bool {\n        return (left.x == right.x) && (left.y == right.y)\n    }\n    static func != (left: Vector2D, right: Vector2D) -> Bool {\n        return !(left == right)\n    }\n}\nlet twoThree = Vector2D(x: 2.0, y: 3.0)\nlet anotherTwoThree = Vector2D(x: 2.0, y: 3.0)\nif twoThree == anotherTwoThree {\n    print(\"These two vectors are equivilent.\")\n}\n\n\n// Custom Operators\n//  Custom operators can be defined only with the characters / = - + * % < > ! & | ^ . ~\n\n// +++ prefix doubling incrementer\nprefix operator +++\nextension Vector2D {\n    static prefix func +++ (vector: inout Vector2D) -> Vector2D {\n        vector += vector\n        return vector\n    }\n}\nvar toBeDoubled = Vector2D(x: 1.0, y: 4.0)\nlet afterDoubling = +++toBeDoubled\n\n\n// Precedence and Associativity for Custom Infix Operators\ninfix operator +-: AdditionPrecedence\nextension Vector2D {\n    static func +- (left: Vector2D, right: Vector2D) -> Vector2D {\n        return Vector2D(x: left.x + right.x, y: left.y - right.y)\n    }\n}\nlet firstVector = Vector2D(x: 1.0, y: 2.0)\nlet secondVector = Vector2D(x: 3.0, y: 4.0)\nlet plusMinusVector = firstVector +- secondVector\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/The Swift Programming Language/LanguageGuide/25-AdvancedOperators.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/AdoptingCocoaDesignPatterns.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/AdoptingCocoaDesignPatterns.playground/section-1.swift",
    "content": "// Adopting Cocoa Design Patterns\n\nimport Cocoa\n\n// Delegation\n/*\nif let fullScreenSize = myDelegate?.window?(myWindow, willUseFullScreenContentSize: mySize) {\n    println(NSStringFromSize(fullScreenSize))\n}\n*/\n// 1. Check that myDelegate is not nil.\n// 2. Check that myDelegate implements the method window:willUseFullScreenContentSize:.\n// 3. If 1 and 2 hold true, invoke the method and assign the result of the method to the value named fullScreenSize.\n// 4. Print the return value of the method.\n//  In a pure Swift app, type the delegate property as an optional NSWindowDelegate object and assign it an initial value of nil.\n\nclass MyDelegate: NSObject, NSWindowDelegate {\n    func window(_ window: NSWindow, willUseFullScreenContentSize proposedSize: NSSize) -> NSSize {\n        return proposedSize\n    }\n}\nlet myWindow = NSWindow()\nmyWindow.delegate = MyDelegate()\n//if let fullScreenSize = myWindow.delegate?.window(myWindow, willUseFullScreenContentSize: NSSize()) {\n//    print(NSStringFromSize(fullScreenSize))\n//}\n\n\n// Lazy Initialization\n\n\n// Error Reporting\n//  Error reporting in Swift follows the same pattern it does in Objective-C.\n//  In the simplest case, you return a Bool value from the function to indicate whether or not it succeeded.\n//  When you need to report the reason for the error, you can add to the function an NSError out parameter of type NSErrorPointer. This type is roughly equivalent to Objective-C’s NSError **. You can use the prefix & operator to pass in a reference to an optional NSError type as an NSErrorPointer object, as shown in the code listing below.\n/*\nvar writeError: NSError?\nlet written = myString.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding, error: &writeError)\nif !written {\n    if let error = writeError {\n        println(\"write failure: \\(error.localizedDescription)\")\n    }\n}\n*/\n\n\n// Target-Action\n// Basically the same as in Objective-C\n\n\n// Introspection\n// In  ObjC you use isKindOfClass: and conformsToProtocol:\n// In Swift you use the is operator and the as? operator to downcast\n/*if errorPointer is NSButton {\n    println(\"\\(typeName) is a string\")\n} else {\n    println(\"typeName is not a string\")\n}\n\nif let button = errorPointer as? NSErrorPointer {\n    \n}\n*/\n//  Checking for and casting to a protocol follows exactly the same syntax as checking for and casting to a class.\n/*\nif let dataSource = object as? UITableViewDataSource {\n    // object conforms to UITableViewDataSource and is bound to dataSource\n} else {\n    // object not conform to UITableViewDataSource\n}\n*/\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/BasicSetup.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/BasicSetup.playground/section-1.swift",
    "content": "// Basic Setup\n\n//  Swift is designed to provide seamless compatibility with Cocoa and Objective-C.\n\n/* This guide covers three important aspects of the compatability of Objective-C and Swift\n        - Interoperability, lets you interface between Swift and Objective-C code.\n        - Mix and Match, allows you to create mixed language apps\n        - Migration, from objective-C code to Swift\n*/\n\n\n// Understanding the Swift Import Process\n//  Any Objective-C framework (or C library) that’s accessible as a module can be imported directly into Swift.\n\nimport Foundation\n\n// The import Process\n// - Objective-C framworks vend APIs in header files.\n// - In Swift those header files rae compiled down to Objective-C modules\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/BasicSetup.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/InteractingWithC-APIs.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx' runInFullSimulator='YES'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/InteractingWithC-APIs.playground/section-1.swift",
    "content": "// Interacting with C APIs\n\nimport Foundation\n\n// Primitive Types\n//  Swift provides equivalents of C primitive integer types—for example, char, int, float, and double. \n//  However, there is no implicit conversion between these types and core Swift integer types, such as Int. Therefore, use these types if your code specifically requires them, but use Int wherever possible otherwise.\n/*\n    C Type              Swift Type\n    bool                CBool\n    char, signed char   CChar\n    unsigned char       CUnsignedChar\n    short               CShort\n    unsigned short      CUnsignedShort\n    int                 CInt\n    unsigned int        CUnsignedInt\n    long                CLong\n    unsigned long       CUnsignedLong\n    long long           CLongLong\n    unsigned long long  CUnsignedLongLong\n    wchar_t             CWideChar\n    char16_t            CChar16\n    char32_t            CChar32\n    float               CFloat\n    double              CDouble\n*/\n\n// Enumerations\n//  Swift imports as a Swift enumeration any C-style enumeration marked with the NS_ENUM macro.\n/*\nObjective-C\ntypedef NS_ENUM(NSInteger, UITableViewCellStyle) {\n    UITableViewCellStyleDefault,\n    UITableViewCellStyleValue1,\n    UITableViewCellStyleValue2,\n    UITableViewCellStyleSubtitle\n}\n*/\nenum UITableViewCellStyle: Int {\n    case Default\n    case Value1\n    case Value2\n    case Subtitle\n}\n//  Swift also imports options marked with the NS_OPTIONS macro. Whereas options behave similarly to imported enumerations, options can also support some bitwise operations, such as &, |, and ~.\n\n\n// Pointers\n/* For Arguments\n    C Syntax        Swift Syntax\n------------------  -----------------------\n    const void *    CConstVoidPointer\n    void *          CMutableVoidPointer\n    const Type *    CConstPointer<Type>\n    Type *          CMutablePointer<Type>\n*/\n/* For return types, variables, and argument types more than one pointer level deep\n    C Syntax        Swift Syntax\n------------------  -----------------------\n    void *          COpaquePointer\n    Type *          UnsafePointer<Type>\n*/\n/* For Class Types\n    C Syntax        Swift Syntax\n------------------  -----------------------\n    Type * const *  CConstPointer<Type>\n    Type * __strong *   CMutablePointer<Type>\n    Type **         AutoreleasingUnsafePointer<Type>\n*/\n\n\n// C Mutable Pointers\n//  When a function is declared as taking a CMutablePointer<Type> argument, it can accept any of the following\n//  - nil, which is passed as a null pointer\n//  - A CMutablePointer<Type> value\n//  - An in-out expression whose operand is a stored lvalue of type Type, which is passed as the address of the lvalue\n//  - An in-out Type[] value, which is passed as a pointer to the start of the array, and lifetime-extended for the duration of the call\nfunc takesAMutablePointer(x: UnsafePointer<Float>) {\n    // Does something\n}\nvar x: Float = 0.0\nvar p: UnsafePointer<Float> = nil\nvar a: [Float] = [1.0, 2.0, 3.0]\ntakesAMutablePointer(nil)\ntakesAMutablePointer(p)\ntakesAMutablePointer(&x)\ntakesAMutablePointer(&a)\n\n/*\nfunc takesAMutablePointer(x: UnsafePointer<Type>) {\n    \n}\nvar y: Int = 0\nvar p: UnsafePointer<Float> = nil\nvar q: UnsafePointer<Int> = nil\n\nvar b: [Int] = [1, 2, 3]\n\n*/\n\n// C Const Pointers\n//  CConstPointer<Type> argument, it can accept any of the following:\n//  - nil, which is passed as a null pointer\n//  - A CMutablePointer<Type>, CMutableVoidPointer, CConstPointer<Type>, CConstVoidPointer, or AutoreleasingUnsafePointer<Type> value, which is converted to CConstPointer<Type> if necessary\n//  - An in-out expression whose operand is an lvalue of type Type, which is passed as the address of the lvalue\n//  - A Type[] value, which is passed as a pointer to the start of the array, and lifetime-extended for the duration of the call\n\nfunc takesAMutableVoidPointer(x:UnsafeMutablePointer<Void>) {\n    \n}\nvar x2: Float = 0.0, y2: Int = 0\nvar p2: UnsafeMutablePointer<Float> = nil, q2: UnsafeMutablePointer<Int> = nil\nvar a2: [Float] = [1.0, 2.0, 3.0], b2: [Int] = [1,2,3]\ntakesAMutableVoidPointer(nil)\ntakesAMutableVoidPointer(p2)\ntakesAMutableVoidPointer(p2)\ntakesAMutableVoidPointer(&x2)\ntakesAMutableVoidPointer(&y2)\ntakesAMutableVoidPointer(&a2)\ntakesAMutableVoidPointer(&b2)\n\n\n\n// AutoreleasingUnsafePointer\n//  AutoreleasingUnsafePointer<Type>, it can accept any of the following:\n//  - nil, which is passed as a null pointer\n//  - An AutoreleasingUnsafePointer<Type> value\n//  - An in-out expression, whose operand is primitive-copied to a temporary nonowning buffer. The address of that buffer is passed to the callee, and on return, the value in the buffer is loaded, retained, and reassigned into the operand.\nfunc takesAnAutoreleasingPointer(x: AutoreleasingUnsafeMutablePointer<NSDate?>) {\n    /* ... */\n}\nvar z: NSDate? = nil\nvar r: AutoreleasingUnsafeMutablePointer<NSDate?> = nil\ntakesAnAutoreleasingPointer(nil)\ntakesAnAutoreleasingPointer(r)\ntakesAnAutoreleasingPointer(&z)\n\n\n// Global Constants\n//  Global constants defined in C and Objective-C source files are automatically imported by the Swift compiler as Swift global constants.\n\n\n// Preprocessor Directives\n//  The Swift compiler does not include a preprocessor. Instead, it takes advantage of compile-time attributes, build configurations, and language features to accomplish the same functionality. For this reason, preprocessor directives are not imported in Swift.\n// #define FADE_ANIMATION_DURATION 0.35\nlet FADE_ANIMATION_DURATION = 0.35\n//  the compiler automatically imports simple macros defined in C and Objective-C source\n// Complex Macros are not transferred across.\n\n\n// Build Configurations\n// Swift code can be conditionally compiled based on the evaluation of Build Configurations.\n// Build configurations include the literals true and false, command line flags and the platform testing functions listed below.\n// You can specify command line flags using -D <#flag#>.\n/*\n    Function        Valid Arguments\n------------------  -----------------------\n    os()            OSX, iOS\n    arch()          x86_64, arm, arm64, i386\n*/\n\n/*\n#if <#build configuration#> && !<#build configuration#>\n    <#statements#>\n#elseif <#build configuration#>\n    <#statements#>\n#else\n    <#statements#>\n#endif\n*/\n//  Conditional compilation statements in Swift must completely surround blocks of code that are self-contained and syntactically valid.\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/InteractingWithC-APIs.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/InteractingWithObjective-C-APIs.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='iphonesimulator'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/InteractingWithObjective-C-APIs.playground/section-1.swift",
    "content": "//: # Interacting with Objective-C APIs\nimport UIKit\n//import CoreGraphics\n//import Foundation\n\n//: ## Initialization\n\n// UITableView *myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];\nlet myTableView: UITableView = UITableView(frame: CGRect.zero, style: .grouped)\n\nlet myTextField = UITextField(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 40.0))\n\n// Objective-C Factory Methods\n// UIColor *color = [UIColor colorWithRed: 0.5 green:0.0 blue:0.5 alpha:1.0]\nlet color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)\n\n//: ## Failable Initialization\nif let image = UIImage(contentsOfFile: \"MyImage.png\") {\n    print(image)\n} else {\n    print(\"UIImage initialization failed\")\n}\n\n\n//: ## Accessing Properties\nmyTextField.textColor = UIColor.darkGray\nmyTextField.text = \"Hello world\"\n\n//:  In Objective-C, a method that returns a value and takes no arguments can be treated as an implicit getter—and be called using the same syntax as a getter for a property. This is not the case in Swift. In Swift, only properties that are written using the @property syntax in Objective-C are imported as properties.\n\n\n//: ## Working with Methods\n//:  When Objective-C methods come over to Swift,\n//: - the first part of an Objective-C selector becomes the base method name and appears outside the parentheses.\n//: - The first argument appears immediately inside the parentheses, without a name.\n//: - The rest of the selector pieces correspond to argument names and go inside the parentheses.\n//: - All selector pieces are required at the call site.\n\nlet mySubview = UIView()\n// [myTableView insertSubview:mySubview atIndex:2];\nmyTableView.insertSubview(mySubview, at: 2)\nmyTableView.layoutIfNeeded() // Parenthesis still required despite lack of arguments\n\n\n//: ## id Compatibility\n//:  AnyObject is a protocol type.\n//:  The AnyObject protocol allows you to write type-safe Swift code while maintaining the flexibility of an untyped object. Because of the additional safety provided by the AnyObject protocol, Swift imports id as AnyObject.\n\nvar x: Any = \"hello\" as String\nx as? String\nx as? NSString\n\nx = \"goodbye\" as NSString\nx as? String\nx as? NSString\n\n// Downcasting Any\nlet userDefaults = UserDefaults.standard\nlet lastRefreshDate = userDefaults.object(forKey: \"LastRefreshDate\") // lastRefreshDate is of type Any?\nif let date = lastRefreshDate as? Date {\n    print(\"\\(date.timeIntervalSinceReferenceDate)\")\n}\n\n// If you are cetain of the type of the object, you can use the forced downcast operator\n\n// let myDate = lastRefreshDate as! Date\n// let timeInterval = myDate.timeIntervalSinceReferenceDate\n\n\n// Dynamic Method Lookup\nvar myObject: AnyObject = UITableViewCell()\nmyObject = NSDate()\nlet futureDate = myObject.addingTimeInterval(10)\nlet timeSinceNow = myObject.timeIntervalSinceNow\n\n\n// Unrecognized Selectors and Optional Chaining\n// myObject.character(at: 5) // crash, myObject doesn't respond to that method\n\nlet myCount = myObject.count                // Int? type and nil value\nlet myChar = myObject.character?(at: 5)     // unichar? type and nil value\nif let fifthCharacter = myObject.character?(at: 5) {\n    print(\"Found \\(fifthCharacter) at index 5\")\n}\n\n\n//: ## Nullability and Optionals\n//:  Swift makes all classes in argument types and return types optional in imported Objective-C APIs.\n//:  Swift imports object types as implicitly unwrapped optionals.\nvar nulableProperty: Any?\nvar nonNullProperty: Any\nvar unannotatedProperty: Any!\n\nfunc returnsNonNullValue() -> Any { return false }\nfunc takesNonNullParameter(value: Any) {}\n\nfunc returnsNullableValue() -> Any? { return nil }\nfunc takesNullableParameter(value: Any?) {}\n\nfunc returnsUnannotatedValue() -> Any! { return false }\nfunc takesUnannotatedParameter(value: Any!) {}\n\n\n// Extensions\nextension UIBezierPath {\n    convenience init(triangleSideLength: CGFloat, origin: CGPoint) {\n        self.init()\n        let squareRoot = CGFloat(sqrt(3.0))\n        let altitude = (squareRoot * triangleSideLength) / 2\n        move(to: origin)\n        addLine(to: CGPoint(x: origin.x + triangleSideLength, y: origin.x))\n        addLine(to: CGPoint(x: origin.x + triangleSideLength / 2, y: origin.y + altitude))\n        close()\n    }\n}\n\n//  You can use extensions to add properties (including class and static properties). However, these properties must be computed; extensions can’t add stored properties to classes, structures, or enumerations.\nextension CGRect {\n    var area: CGFloat {\n        return width * height\n    }\n}\nlet rect = CGRect(x: 0.0, y: 0.0, width: 10.0, height: 50.0)\nlet area = rect.area\n\n\n// Closures\n//  Objective-C blocks are automatically imported as Swift closures.\n\n// void (^completionBlock)(NSData *, NSError *) = ^(NSData *data, NSError *error) { /* ... */ }\nlet completionBlock: (Data) -> Void = { data in\n    /* ... */\n}\n\n// Avoiding String Reference Cycles When Capturing self\n/*\nself.closure = { [unowned self] in\n    self.doSomething()\n}\n*/\n\n// Object Comparison\n//  Equality (==), compares the contents of the objects. \n//  Identity (===), determines whether or not the constants or variables refer to the same object instance.\n//  Swift invokes the isEqual: method defined on the NSObject class. The NSObject class only performs an identity comparison, so you should implement your own isEqual: method in classes that derive from the NSObject class.\n//\n\n// Swift Type Compatibility\n//  The @objc attribute makes your Swift API available in Objective-C and the Objective-C runtime.\n/*\nclass Jukebox: NSObject {\n    var library: Set<String>\n    var nowPlaying: String?\n    \n    var isCurrentlyPlaying: Bool {\n        return nowPlaying != nil\n    }\n    \n    static var favoritesPlaylist: [String] {\n        // return an array of song names\n    }\n    \n    init(songs: String...) {\n        self.library = Set<String>(songs)\n    }\n    \n    func playSong(named name: String) throws {\n        // play song or throw and error if unavailable\n    }\n}\n*/\n\n// Configuring Swift Interfaces in Objective-C\n@objc(Color)\nenum Цвет: Int {\n    @objc(Red)\n    case Красный\n    \n    @objc(Black)\n    case Черный\n}\n\n@objc(Squirrel)\nclass Белка: NSObject {\n    @objc(color)\n    var цвет: Цвет = .Красный\n    \n    @objc(initWithName:)\n    init(имя: String) {\n        // ...\n    }\n    @objc(hideNuts:inTree:)\n    func прячьОрехи(количество: Int, вДереве дерево: Цвет) { // Error\n        // ...\n    }\n}\n\n\n// Requiring Dynamic Dispatch\n// Selectors\n//  An Objective-C selector is a type that refers to the name of an Objective-C method. In Swift, Objective-C selectors are represented by the Selector structure.\n//  In Swift string literals can be automatically converted to selectors\nclass MyViewController: UIViewController {\n    let myButton = UIButton(frame: CGRect(x: 0, y: 0, width: 100, height: 50))\n    \n    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {\n        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)\n        let action = #selector(MyViewController.tappedButton)\n        myButton.addTarget(self, action: action, for: .touchUpInside)\n    }\n    \n    func tappedButton(sender: UIButton!) {\n        print(\"tapped button\")\n    }\n    \n    required init?(coder: NSCoder) {\n        super.init(coder: coder)\n    }\n}\n\n\n// Unsafe Invocation of Objective-C Methods\nlet string: NSString = \"Hello, Cocoa!\"\nlet selector = #selector(NSString.lowercased(with:))\nlet locale = Locale.current\nif let result = string.perform(selector, with: locale) {\n    print(result.takeUnretainedValue())\n}\n\nlet array: NSArray = [\"delta\", \"alpha\", \"zulu\"]\nlet anotherSelector = #selector(getter: NSDictionary.allKeys)\n// array.perform(selector) // Raises an exception because NSArray does not respond to this selector\n\n\n// Keys and Key Paths\nclass Person: NSObject {\n    var name: String\n    var friends: [Person] = []\n    var bestFriend: Person? = nil\n    \n    init(name: String) {\n        self.name = name\n    }\n}\n\nlet gabrielle = Person(name: \"Gabrielle\")\nlet jim = Person(name: \"Jim\")\nlet yuanyuan = Person(name: \"Yuanyuan\")\ngabrielle.friends = [jim, yuanyuan]\ngabrielle.bestFriend = yuanyuan\n\n#keyPath(Person.name)\ngabrielle.value(forKey: #keyPath(Person.name))\n#keyPath(Person.bestFriend.name)\ngabrielle.value(forKeyPath: #keyPath(Person.bestFriend.name))\n#keyPath(Person.friends.name)\ngabrielle.value(forKeyPath: #keyPath(Person.friends.name))\n\nlet personNameKeyPath = #keyPath(Person.name)\nyuanyuan.value(forKeyPath: personNameKeyPath)\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/Mix&Match.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='macosx'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/Mix&Match.playground/section-1.swift",
    "content": "// Mix and Match\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/Mix&Match.playground/timeline.xctimeline",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Timeline\n   version = \"3.0\">\n   <TimelineItems>\n   </TimelineItems>\n</Timeline>\n"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/WorkingWithCocoaDataTypes.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='3.0' sdk='iphonesimulator'>\n    <sections>\n        <code source-file-name='section-1.swift'/>\n    </sections>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/Using Swift With Cocoa And Objective-C/WorkingWithCocoaDataTypes.playground/section-1.swift",
    "content": "// Working with Cocoa Frameworks\n//  Data types that are convertible or can be used interchangeably are referred to as bridged data types.\n\nimport UIKit\n\n// Strings\n// Swift automatically bridges between the String type and the NSString class.\n\n// To enable string bridging, just import Foundation.\nimport Foundation\nlet string: String = \"abc\"\nlet bridgedString: NSString = string as NSString\n\nlet stringLiteral: NSString = \"123\"\nif let integerValue = Int(stringLiteral as String) {\n    print(\"\\(stringLiteral) is the integer \\(integerValue)\")\n}\n\n\n// Numbers\n// Swift automatically bridges from Int, UInt, Float, Double, Bool to NSNumber\nlet number = 42\nlet bridgedNumber: NSNumber = number as NSNumber\n\nlet integerLiteral: NSNumber = 5\nlet floatLiteral: NSNumber = 3.14159\nlet booleanLiteral: NSNumber = true\n\n\n// Arrays\n//  Swift automatically bridges from NSArray to the native Array structure. The bridged class will be of type AnyObject[]. You can downcast the AnyObject[] to a more specific type. This will return an optional type though as it is not possible to know that all of the elements of the array can be downcast to the specified type until runtime.\n\nlet schoolSupplies: NSArray = [\"Pencil\", \"Eraser\", \"Notebook\"]\n\n// Sets\nlet amenities: NSSet = [\"Sauna\", \"Steam Room\", \"Jacuzzi\"]\n\n// Dictionaries\nlet medalRankings: NSDictionary = [\"Gold\": \"1st Place\", \"Silver\": \"2nd Place\", \"Bronze\": \"3rd Place\"]\n\n\n// Core Foundation\n//  Core Foundation types are automatically imported as full-fledged Swift classes. Wherever memory management annotations have been provided, Swift automatically manages the memory of Core Foundation objects, including Core Foundation objects that you instantiate yourself.\n\n// Remapped Types\n//  When Swift imports Core Foundation types, the compiler remaps the names of these types. The compiler removes Ref from the end of each type name because all Swift classes are reference types, therefore the suffix is redundant.\n//  The Core Foundation CFTypeRef type completely remaps to the AnyObject type. Wherever you would use CFTypeRef, you should now use AnyObject in your code.\n\n// Memory Managed Objects\n//  Core Foundation objects returned from annotated APIs are automatically memory managed in Swift—you do not need to invoke the CFRetain, CFRelease, or CFAutorelease functions yourself.\n\n// Unmanaged Objects\n//  When Swift imports APIs that have not been annotated, the compiler cannot automatically memory manage the returned Core Foundation objects. Swift wraps these returned Core Foundation objects in an Unmanaged<T> structure. All indirectly returned Core Foundation objects are unmanaged as well. For example, here’s an unannotated C function:\n/*\nObjective-C\nCFStringRef StringByAddingTwoStrings(CFStringRef string1, CFStringRef string2)\n\nSwift\nfunc StringByAddingTwoStrings(CFString!, CFString!) -> Unmanaged<CFString>!\n*/\n//  When you receive an unmanaged object from an unannotated API, you should immediately convert it to a memory managed object before you work with it. Use takeUnretainedValue() or takeRetainedValue()\n/*\nlet memoryManagedResult = StringByAddingTwoStrings(str1, str2).takeUnretainedValue()\n*/\n\n\n// Unified Logging\n// The unified logging system provides an API for capturing messaging across all levels of the system, and is a replacement for the NSLog function in the Foundation framework.\n\n/*\nimport os.log\nos_log(\"This is a log message.\")\n\nlet fileSize = 1234567890\nos_log(\"Finished downloading file. Size: %{iec-bytes}d\", fileSize)\n\nos_log(\"This is additional info that may be helpful for troubleshooting.\", type: .info)\n\nlet customLog = OSLog(subsystem: \"com.your_company.your_subsystem_name.plist\", category: \"your_category_name\")\nos_log(\"This is info that may be helpful during development or debugging.\", log: customLog, type: .debug)\n*/\n\n\n\n\n\n"
  },
  {
    "path": "Swift-Playgrounds/WWDC/2014/AdvancedSwift.playground/Contents.swift",
    "content": "// WWDC 2014 - Advanced Swift\n\n\nclass Thing {\n    init(_ location: Thing?, _ name: String, _ longDescription: String) {\n        self.location = location\n        self.name = name\n        self.longDescription = longDescription\n    }\n    weak var location: Thing?\n    var name: String\n    var longDescription: String\n    \n}\n\nlet westOfHouse = Thing(nil, \"house\", \"West of House\")\nlet westWallOfHouse = Thing(westOfHouse, \"wall\", \"The Plaster has crumbled away, leaving the wood beneath to rot.\")\nlet pathWestOfHouse = Thing(westOfHouse, \"path\", \"An overgrown path leads south around the corner of the house.\")\n\nprotocol Pullable {\n    func pull()\n}\n\nclass Boards: Thing, Pullable {\n    func pull() {\n        if location === westWallOfHouse {\n            print(\"They come off with little effort.\")\n            location = westOfHouse\n        } else {\n            print(\"Think of the splinters!\")\n        }\n    }\n}\n\n\nlet boards = Boards(westWallOfHouse, \"boards\", \"They've been nailed directly to the wall.\")\n\n/*\nfunc performPull(object: Thing) {\n    if let pullableObject = object as Pullable {\n        pullableObject.pull()\n    } else {\n        println(\"You aren't sure how to print a \\(object.name).\")\n    }\n}\n*/\n\nextension Thing: CustomStringConvertible {\n    var description: String { return name }\n}\n\nextension Thing {\n    var nameWithArticle: String {\n        return \"a \" + name\n    }\n}\n\nvar object = Thing(westOfHouse, \"wall\", \"The Plaster has crumbled away, leaving the wood beneath to rot.\")\n\n// Printable doesn't work in a playground yet (Beta 3)\nprint(\"You aren't sure how to pull \\(object)\")\n//println(\"You aren't sure how to pull \\(object.description)\")\n//println(\"You aren't sure how to pull \\(an ~ object)\")\n\n/*\n// Special Protocols\n// LogicValue                   if logicValue {\n// Printable                    \"\\(printable)\"\n// Sequence                     for x in sequence\n// IntegerLiteralConvertible    65536\n// Float LIteralConvertible     1.0\n// StringLiteralConvertible     \"abc\"\n// ArrayLiteralConvertible      [ a, b, c ]\n// DictionaryLiteralConvertible [ a: x, b: y ]\n\nprotocol Printable {\n    var description: String { get }\n}\n*/\n\n/*\n// Overloading an operator\noperator infix ~ {}  // Define the operator you want to use\n// infix, postfix and prefix are options\nfunc ~ (decorator: (Thing) -> String, object: Thing -> String {\n    return decorator(object)\n    })\n\nfunc an(object: Thing) -> String {\n    return object.nameWithArticle\n}\n\nlet mud = Thing(westOfHouse, \"mud\", \"I don't know\")\n\nprintln(\"You aren't sure how to pull \\(an ~ mud).\")\n*/\n\n// Defining a Place\nenum Direction {\n    case North, South, East, West\n}\n\n/*\nclass Place: Thing {\n    //init(_ name: String, _ longDescription: String) {\n    //    super.init(<#Thing?#>, <#String#>, <#String#>)\n    //}\n    //var exits: Dictionary<Direction, Place> =\n*/"
  },
  {
    "path": "Swift-Playgrounds/WWDC/2014/AdvancedSwift.playground/contents.xcplayground",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<playground version='5.0' target-platform='osx'>\n    <timeline fileName='timeline.xctimeline'/>\n</playground>"
  },
  {
    "path": "Swift-Playgrounds/main.swift",
    "content": "//\n//  main.swift\n//  Swift-Playgrounds\n//\n//  Created by Daniel Pink on 5/06/2014.\n//  Copyright (c) 2014 Electronic Innovations. All rights reserved.\n//\n\nimport Cocoa\n\nNSApplicationMain(C_ARGC, C_ARGV)\n"
  },
  {
    "path": "Swift-Playgrounds.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\tE66B1CC01E4C183C00B6593E /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = E66B1CBF1E4C183C00B6593E /* README.md */; };\n\t\tE6C330A81E4C00CD0000AA37 /* icon_56811.png in Resources */ = {isa = PBXBuildFile; fileRef = E6C330A61E4C00CD0000AA37 /* icon_56811.png */; };\n\t\tE6E1BED819401B3600DA4D53 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6E1BED719401B3600DA4D53 /* main.swift */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\tE6E1BEE519401B3600DA4D53 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = E6E1BECA19401B3600DA4D53 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = E6E1BED119401B3600DA4D53;\n\t\t\tremoteInfo = \"Swift-Playgrounds\";\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXFileReference section */\n\t\tE61C4B621E4BFC0200E4E565 /* ASwiftTour.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = ASwiftTour.playground; sourceTree = \"<group>\"; };\n\t\tE61C4B641E4BFC0200E4E565 /* 01-TheBasics.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"01-TheBasics.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B651E4BFC0200E4E565 /* 02-BasicOperators.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"02-BasicOperators.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B661E4BFC0200E4E565 /* 03-StringsAndCharacters.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"03-StringsAndCharacters.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B671E4BFC0200E4E565 /* 04-CollectionTypes.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"04-CollectionTypes.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B681E4BFC0200E4E565 /* 05-ControlFlow.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"05-ControlFlow.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B691E4BFC0200E4E565 /* 06-Functions.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"06-Functions.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6A1E4BFC0200E4E565 /* 07-Closures.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"07-Closures.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6B1E4BFC0200E4E565 /* 08-Enumerations.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"08-Enumerations.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6C1E4BFC0200E4E565 /* 09-ClassesAndStructures.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"09-ClassesAndStructures.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6D1E4BFC0200E4E565 /* 10-Properties.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"10-Properties.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6E1E4BFC0200E4E565 /* 11-Methods.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"11-Methods.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B6F1E4BFC0200E4E565 /* 12-Subscripts.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"12-Subscripts.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B701E4BFC0200E4E565 /* 13-Inheritance.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"13-Inheritance.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B711E4BFC0200E4E565 /* 14-Initialization.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"14-Initialization.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B721E4BFC0200E4E565 /* 15-Deinitialization.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"15-Deinitialization.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B731E4BFC0200E4E565 /* 16-AutomaticReferenceCounting.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"16-AutomaticReferenceCounting.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B741E4BFC0200E4E565 /* 17-OptionalChaining.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"17-OptionalChaining.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B751E4BFC0200E4E565 /* 18-ErrorHandling.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"18-ErrorHandling.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B761E4BFC0200E4E565 /* 19-TypeCasting.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"19-TypeCasting.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B771E4BFC0200E4E565 /* 20-NestedTypes.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"20-NestedTypes.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B781E4BFC0200E4E565 /* 21-Extensions.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"21-Extensions.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B791E4BFC0200E4E565 /* 22-Protocols.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"22-Protocols.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B7A1E4BFC0300E4E565 /* 23-Generics.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"23-Generics.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B7B1E4BFC0300E4E565 /* 24-AccessControl.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"24-AccessControl.playground\"; sourceTree = \"<group>\"; };\n\t\tE61C4B7C1E4BFC0300E4E565 /* 25-AdvancedOperators.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"25-AdvancedOperators.playground\"; sourceTree = \"<group>\"; };\n\t\tE66B1CBF1E4C183C00B6593E /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = \"<group>\"; };\n\t\tE6C3307F1E4BFCCF0000AA37 /* Swift-Playgrounds.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"Swift-Playgrounds.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\tE6C330801E4BFCCF0000AA37 /* Swift-PlaygroundsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = \"Swift-PlaygroundsTests.xctest\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\tE6C330831E4C008E0000AA37 /* AdoptingCocoaDesignPatterns.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = AdoptingCocoaDesignPatterns.playground; sourceTree = \"<group>\"; };\n\t\tE6C330841E4C008E0000AA37 /* BasicSetup.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = BasicSetup.playground; sourceTree = \"<group>\"; };\n\t\tE6C330851E4C008E0000AA37 /* InteractingWithC-APIs.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"InteractingWithC-APIs.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330861E4C008E0000AA37 /* InteractingWithObjective-C-APIs.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"InteractingWithObjective-C-APIs.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330871E4C008E0000AA37 /* Mix&Match.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"Mix&Match.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330881E4C008E0000AA37 /* WorkingWithCocoaDataTypes.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = WorkingWithCocoaDataTypes.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308A1E4C00A50000AA37 /* Array.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Array.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308B1E4C00A50000AA37 /* Dictionary.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Dictionary.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308C1E4C00A50000AA37 /* FreeFunctions.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = FreeFunctions.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308D1E4C00A50000AA37 /* NumericTypes.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = NumericTypes.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308E1E4C00A50000AA37 /* Protocols.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Protocols.playground; sourceTree = \"<group>\"; };\n\t\tE6C3308F1E4C00A50000AA37 /* String.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = String.playground; sourceTree = \"<group>\"; };\n\t\tE6C330901E4C00A50000AA37 /* Undocumented.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Undocumented.playground; sourceTree = \"<group>\"; };\n\t\tE6C330921E4C00CD0000AA37 /* 2014-08-11-SwiftOperators.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-11-SwiftOperators.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330931E4C00CD0000AA37 /* Cheryls-Birthday-Alternative-1.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"Cheryls-Birthday-Alternative-1.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330941E4C00CD0000AA37 /* Cheryls-Birthday.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"Cheryls-Birthday.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330951E4C00CD0000AA37 /* WritingSwiftClassesWithObjectiveCBehaviour.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = WritingSwiftClassesWithObjectiveCBehaviour.playground; sourceTree = \"<group>\"; };\n\t\tE6C330971E4C00CD0000AA37 /* 2014-08-08-LockingInSwift.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-08-LockingInSwift.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330991E4C00CD0000AA37 /* 2014-08-18-SwiftLiteralConvertibles.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-18-SwiftLiteralConvertibles.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C3309B1E4C00CD0000AA37 /* 2014-07-23-AccessControl.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-07-23-AccessControl.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C3309C1E4C00CD0000AA37 /* 2014-07-28-InteractingWithCPointers.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-07-28-InteractingWithCPointers.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C3309D1E4C00CD0000AA37 /* 2014-08-05-Boolean.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-05-Boolean.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C3309E1E4C00CD0000AA37 /* 2014-08-15-ValueAndReferenceTypes.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-15-ValueAndReferenceTypes.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C3309F1E4C00CD0000AA37 /* 2014-08-27-OptionalCaseStudy-valuesForKeys.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = \"2014-08-27-OptionalCaseStudy-valuesForKeys.playground\"; sourceTree = \"<group>\"; };\n\t\tE6C330A21E4C00CD0000AA37 /* AdvancedSwift.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = AdvancedSwift.playground; sourceTree = \"<group>\"; };\n\t\tE6C330A51E4C00CD0000AA37 /* GameDevUniversity.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = GameDevUniversity.playground; sourceTree = \"<group>\"; };\n\t\tE6C330A61E4C00CD0000AA37 /* icon_56811.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_56811.png; sourceTree = \"<group>\"; };\n\t\tE6C330A71E4C00CD0000AA37 /* SpriteKitTestbed.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = SpriteKitTestbed.playground; sourceTree = \"<group>\"; };\n\t\tE6E1BED619401B3600DA4D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\tE6E1BED719401B3600DA4D53 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\tE6E1BECF19401B3600DA4D53 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\tE6E1BEE119401B3600DA4D53 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\tE61C4B611E4BFC0200E4E565 /* The Swift Programming Language */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE61C4B621E4BFC0200E4E565 /* ASwiftTour.playground */,\n\t\t\t\tE61C4B631E4BFC0200E4E565 /* LanguageGuide */,\n\t\t\t);\n\t\t\tpath = \"The Swift Programming Language\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE61C4B631E4BFC0200E4E565 /* LanguageGuide */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE61C4B641E4BFC0200E4E565 /* 01-TheBasics.playground */,\n\t\t\t\tE61C4B651E4BFC0200E4E565 /* 02-BasicOperators.playground */,\n\t\t\t\tE61C4B661E4BFC0200E4E565 /* 03-StringsAndCharacters.playground */,\n\t\t\t\tE61C4B671E4BFC0200E4E565 /* 04-CollectionTypes.playground */,\n\t\t\t\tE61C4B681E4BFC0200E4E565 /* 05-ControlFlow.playground */,\n\t\t\t\tE61C4B691E4BFC0200E4E565 /* 06-Functions.playground */,\n\t\t\t\tE61C4B6A1E4BFC0200E4E565 /* 07-Closures.playground */,\n\t\t\t\tE61C4B6B1E4BFC0200E4E565 /* 08-Enumerations.playground */,\n\t\t\t\tE61C4B6C1E4BFC0200E4E565 /* 09-ClassesAndStructures.playground */,\n\t\t\t\tE61C4B6D1E4BFC0200E4E565 /* 10-Properties.playground */,\n\t\t\t\tE61C4B6E1E4BFC0200E4E565 /* 11-Methods.playground */,\n\t\t\t\tE61C4B6F1E4BFC0200E4E565 /* 12-Subscripts.playground */,\n\t\t\t\tE61C4B701E4BFC0200E4E565 /* 13-Inheritance.playground */,\n\t\t\t\tE61C4B711E4BFC0200E4E565 /* 14-Initialization.playground */,\n\t\t\t\tE61C4B721E4BFC0200E4E565 /* 15-Deinitialization.playground */,\n\t\t\t\tE61C4B731E4BFC0200E4E565 /* 16-AutomaticReferenceCounting.playground */,\n\t\t\t\tE61C4B741E4BFC0200E4E565 /* 17-OptionalChaining.playground */,\n\t\t\t\tE61C4B751E4BFC0200E4E565 /* 18-ErrorHandling.playground */,\n\t\t\t\tE61C4B761E4BFC0200E4E565 /* 19-TypeCasting.playground */,\n\t\t\t\tE61C4B771E4BFC0200E4E565 /* 20-NestedTypes.playground */,\n\t\t\t\tE61C4B781E4BFC0200E4E565 /* 21-Extensions.playground */,\n\t\t\t\tE61C4B791E4BFC0200E4E565 /* 22-Protocols.playground */,\n\t\t\t\tE61C4B7A1E4BFC0300E4E565 /* 23-Generics.playground */,\n\t\t\t\tE61C4B7B1E4BFC0300E4E565 /* 24-AccessControl.playground */,\n\t\t\t\tE61C4B7C1E4BFC0300E4E565 /* 25-AdvancedOperators.playground */,\n\t\t\t);\n\t\t\tpath = LanguageGuide;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330821E4C008E0000AA37 /* Using Swift With Cocoa And Objective-C */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330831E4C008E0000AA37 /* AdoptingCocoaDesignPatterns.playground */,\n\t\t\t\tE6C330841E4C008E0000AA37 /* BasicSetup.playground */,\n\t\t\t\tE6C330851E4C008E0000AA37 /* InteractingWithC-APIs.playground */,\n\t\t\t\tE6C330861E4C008E0000AA37 /* InteractingWithObjective-C-APIs.playground */,\n\t\t\t\tE6C330871E4C008E0000AA37 /* Mix&Match.playground */,\n\t\t\t\tE6C330881E4C008E0000AA37 /* WorkingWithCocoaDataTypes.playground */,\n\t\t\t);\n\t\t\tpath = \"Using Swift With Cocoa And Objective-C\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330891E4C00A50000AA37 /* Swift Stanard Library */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C3308A1E4C00A50000AA37 /* Array.playground */,\n\t\t\t\tE6C3308B1E4C00A50000AA37 /* Dictionary.playground */,\n\t\t\t\tE6C3308C1E4C00A50000AA37 /* FreeFunctions.playground */,\n\t\t\t\tE6C3308D1E4C00A50000AA37 /* NumericTypes.playground */,\n\t\t\t\tE6C3308E1E4C00A50000AA37 /* Protocols.playground */,\n\t\t\t\tE6C3308F1E4C00A50000AA37 /* String.playground */,\n\t\t\t\tE6C330901E4C00A50000AA37 /* Undocumented.playground */,\n\t\t\t);\n\t\t\tpath = \"Swift Stanard Library\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330911E4C00CD0000AA37 /* Others */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330921E4C00CD0000AA37 /* 2014-08-11-SwiftOperators.playground */,\n\t\t\t\tE6C330931E4C00CD0000AA37 /* Cheryls-Birthday-Alternative-1.playground */,\n\t\t\t\tE6C330941E4C00CD0000AA37 /* Cheryls-Birthday.playground */,\n\t\t\t\tE6C330951E4C00CD0000AA37 /* WritingSwiftClassesWithObjectiveCBehaviour.playground */,\n\t\t\t);\n\t\t\tpath = Others;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330961E4C00CD0000AA37 /* Blogs */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330971E4C00CD0000AA37 /* 2014-08-08-LockingInSwift.playground */,\n\t\t\t\tE6C330981E4C00CD0000AA37 /* NSHipster */,\n\t\t\t\tE6C3309A1E4C00CD0000AA37 /* Swift Blog */,\n\t\t\t);\n\t\t\tpath = Blogs;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330981E4C00CD0000AA37 /* NSHipster */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330991E4C00CD0000AA37 /* 2014-08-18-SwiftLiteralConvertibles.playground */,\n\t\t\t);\n\t\t\tpath = NSHipster;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C3309A1E4C00CD0000AA37 /* Swift Blog */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C3309B1E4C00CD0000AA37 /* 2014-07-23-AccessControl.playground */,\n\t\t\t\tE6C3309C1E4C00CD0000AA37 /* 2014-07-28-InteractingWithCPointers.playground */,\n\t\t\t\tE6C3309D1E4C00CD0000AA37 /* 2014-08-05-Boolean.playground */,\n\t\t\t\tE6C3309E1E4C00CD0000AA37 /* 2014-08-15-ValueAndReferenceTypes.playground */,\n\t\t\t\tE6C3309F1E4C00CD0000AA37 /* 2014-08-27-OptionalCaseStudy-valuesForKeys.playground */,\n\t\t\t);\n\t\t\tpath = \"Swift Blog\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330A01E4C00CD0000AA37 /* WWDC */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330A11E4C00CD0000AA37 /* 2014 */,\n\t\t\t);\n\t\t\tpath = WWDC;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330A11E4C00CD0000AA37 /* 2014 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330A21E4C00CD0000AA37 /* AdvancedSwift.playground */,\n\t\t\t);\n\t\t\tpath = 2014;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330A31E4C00CD0000AA37 /* Specific Technologies */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330A41E4C00CD0000AA37 /* SpriteKit */,\n\t\t\t);\n\t\t\tpath = \"Specific Technologies\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6C330A41E4C00CD0000AA37 /* SpriteKit */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6C330A51E4C00CD0000AA37 /* GameDevUniversity.playground */,\n\t\t\t\tE6C330A61E4C00CD0000AA37 /* icon_56811.png */,\n\t\t\t\tE6C330A71E4C00CD0000AA37 /* SpriteKitTestbed.playground */,\n\t\t\t);\n\t\t\tpath = SpriteKit;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6E1BEC919401B3600DA4D53 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE66B1CBF1E4C183C00B6593E /* README.md */,\n\t\t\t\tE6E1BED419401B3600DA4D53 /* Swift-Playgrounds */,\n\t\t\t\tE6C3307F1E4BFCCF0000AA37 /* Swift-Playgrounds.app */,\n\t\t\t\tE6C330801E4BFCCF0000AA37 /* Swift-PlaygroundsTests.xctest */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6E1BED419401B3600DA4D53 /* Swift-Playgrounds */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE61C4B611E4BFC0200E4E565 /* The Swift Programming Language */,\n\t\t\t\tE6C330821E4C008E0000AA37 /* Using Swift With Cocoa And Objective-C */,\n\t\t\t\tE6C330891E4C00A50000AA37 /* Swift Stanard Library */,\n\t\t\t\tE6C330911E4C00CD0000AA37 /* Others */,\n\t\t\t\tE6C330961E4C00CD0000AA37 /* Blogs */,\n\t\t\t\tE6C330A01E4C00CD0000AA37 /* WWDC */,\n\t\t\t\tE6C330A31E4C00CD0000AA37 /* Specific Technologies */,\n\t\t\t\tE6E1BED519401B3600DA4D53 /* Supporting Files */,\n\t\t\t);\n\t\t\tpath = \"Swift-Playgrounds\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tE6E1BED519401B3600DA4D53 /* Supporting Files */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tE6E1BED619401B3600DA4D53 /* Info.plist */,\n\t\t\t\tE6E1BED719401B3600DA4D53 /* main.swift */,\n\t\t\t);\n\t\t\tname = \"Supporting Files\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\tE6E1BED119401B3600DA4D53 /* Swift-Playgrounds */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = E6E1BEEE19401B3600DA4D53 /* Build configuration list for PBXNativeTarget \"Swift-Playgrounds\" */;\n\t\t\tbuildPhases = (\n\t\t\t\tE6E1BECE19401B3600DA4D53 /* Sources */,\n\t\t\t\tE6E1BECF19401B3600DA4D53 /* Frameworks */,\n\t\t\t\tE6E1BED019401B3600DA4D53 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"Swift-Playgrounds\";\n\t\t\tproductName = \"Swift-Playgrounds\";\n\t\t\tproductReference = E6C3307F1E4BFCCF0000AA37 /* Swift-Playgrounds.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n\t\tE6E1BEE319401B3600DA4D53 /* Swift-PlaygroundsTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = E6E1BEF119401B3600DA4D53 /* Build configuration list for PBXNativeTarget \"Swift-PlaygroundsTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\tE6E1BEE019401B3600DA4D53 /* Sources */,\n\t\t\t\tE6E1BEE119401B3600DA4D53 /* Frameworks */,\n\t\t\t\tE6E1BEE219401B3600DA4D53 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\tE6E1BEE619401B3600DA4D53 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"Swift-PlaygroundsTests\";\n\t\t\tproductName = \"Swift-PlaygroundsTests\";\n\t\t\tproductReference = E6C330801E4BFCCF0000AA37 /* Swift-PlaygroundsTests.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\tE6E1BECA19401B3600DA4D53 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastSwiftUpdateCheck = 0700;\n\t\t\t\tLastUpgradeCheck = 0700;\n\t\t\t\tORGANIZATIONNAME = \"Electronic Innovations\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\tE6E1BED119401B3600DA4D53 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 6.0;\n\t\t\t\t\t\tLastSwiftMigration = 0820;\n\t\t\t\t\t};\n\t\t\t\t\tE6E1BEE319401B3600DA4D53 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 6.0;\n\t\t\t\t\t\tLastSwiftMigration = 0820;\n\t\t\t\t\t\tTestTargetID = E6E1BED119401B3600DA4D53;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = E6E1BECD19401B3600DA4D53 /* Build configuration list for PBXProject \"Swift-Playgrounds\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = E6E1BEC919401B3600DA4D53;\n\t\t\tproductRefGroup = E6E1BEC919401B3600DA4D53;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\tE6E1BED119401B3600DA4D53 /* Swift-Playgrounds */,\n\t\t\t\tE6E1BEE319401B3600DA4D53 /* Swift-PlaygroundsTests */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\tE6E1BED019401B3600DA4D53 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tE6C330A81E4C00CD0000AA37 /* icon_56811.png in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\tE6E1BEE219401B3600DA4D53 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\tE6E1BECE19401B3600DA4D53 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tE66B1CC01E4C183C00B6593E /* README.md in Sources */,\n\t\t\t\tE6E1BED819401B3600DA4D53 /* main.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\tE6E1BEE019401B3600DA4D53 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\tE6E1BEE619401B3600DA4D53 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = E6E1BED119401B3600DA4D53 /* Swift-Playgrounds */;\n\t\t\ttargetProxy = E6E1BEE519401B3600DA4D53 /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\tE6E1BEEC19401B3600DA4D53 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.9;\n\t\t\t\tMETAL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tE6E1BEED19401B3600DA4D53 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOPY_PHASE_STRIP = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.9;\n\t\t\t\tMETAL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\tE6E1BEEF19401B3600DA4D53 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tINFOPLIST_FILE = \"Swift-Playgrounds/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/../Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"au.com.electronicinnovations.${PRODUCT_NAME:rfc1034identifier}\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tE6E1BEF019401B3600DA4D53 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tINFOPLIST_FILE = \"Swift-Playgrounds/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/../Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"au.com.electronicinnovations.${PRODUCT_NAME:rfc1034identifier}\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\tE6E1BEF219401B3600DA4D53 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tBUNDLE_LOADER = \"$(BUILT_PRODUCTS_DIR)/Swift-Playgrounds.app/Contents/MacOS/Swift-Playgrounds\";\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(DEVELOPER_FRAMEWORKS_DIR)\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = \"Swift-PlaygroundsTests/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks\";\n\t\t\t\tMETAL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"au.com.electronicinnovations.${PRODUCT_NAME:rfc1034identifier}\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t\tTEST_HOST = \"$(BUNDLE_LOADER)\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tE6E1BEF319401B3600DA4D53 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tBUNDLE_LOADER = \"$(BUILT_PRODUCTS_DIR)/Swift-Playgrounds.app/Contents/MacOS/Swift-Playgrounds\";\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(DEVELOPER_FRAMEWORKS_DIR)\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = \"Swift-PlaygroundsTests/Info.plist\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks\";\n\t\t\t\tMETAL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \"au.com.electronicinnovations.${PRODUCT_NAME:rfc1034identifier}\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t\tTEST_HOST = \"$(BUNDLE_LOADER)\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\tE6E1BECD19401B3600DA4D53 /* Build configuration list for PBXProject \"Swift-Playgrounds\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tE6E1BEEC19401B3600DA4D53 /* Debug */,\n\t\t\t\tE6E1BEED19401B3600DA4D53 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\tE6E1BEEE19401B3600DA4D53 /* Build configuration list for PBXNativeTarget \"Swift-Playgrounds\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tE6E1BEEF19401B3600DA4D53 /* Debug */,\n\t\t\t\tE6E1BEF019401B3600DA4D53 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\tE6E1BEF119401B3600DA4D53 /* Build configuration list for PBXNativeTarget \"Swift-PlaygroundsTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tE6E1BEF219401B3600DA4D53 /* Debug */,\n\t\t\t\tE6E1BEF319401B3600DA4D53 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = E6E1BECA19401B3600DA4D53 /* Project object */;\n}\n"
  },
  {
    "path": "Thoughts-Questions.txt",
    "content": "Swift Thoughts and Questions\n\n- How do you get pretty printing of instances in the playground?\n- Could you get a pretty printout of something like a 2D matrix?\n- How does Phase two of object initialization work?\n- In the Deinitialization Chapter is the Bank object (that only contains Type properties and methods) a hacky way of having a singleton?\n- The Player deinitialization method doesn't get called in the playground when the playerOne variable is set to nil.\n\nIn \"Using Swift with Cocoa and Objective-C\"\n- let myTextField = UITextField(frame: CGRect(0.0, 0.0, 200.0, 40.0)) is corrected by the playground autocorrecto to let myTextField = UITextField(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 40.0))\n- myTextField.editing = false is reported as an error as editing is not allowed to be assigned.\n- The following doesn't seem to work in a playground\nlet myLength = myObject.length? \nif let fifthCharacter = myObject.characterAtIndex(5) {\n    println(\"Found \\(fifthCharacter) at index 5\")\n}\n- let squareRoot = Float(sqrt(3)) gives an \"Ambiguous use of sqrt in Beta 3\". It doesn't look like you can call sqrt() on an integer.\n\n- The following code gives a error in the playground no matter what object and UIButton are. \nif object is UIButton {\n    // object is of type UIButton\n} else {\n    // object is not of type UIButton\n}"
  }
]