This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| struct Computr { | |
| typealias Integer = Int | |
| typealias Address = UnsafeMutablePointer<Integer> | |
| var ic: Address = Address.allocate(capacity: 1) | |
| var eax: Integer = 0 | |
| var memory = Address.allocate(capacity: 10) | |
| mutating func addr(at index: Int) -> Address { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Factory { | |
| associatedtype Value = Self | |
| static func make() -> Value | |
| } | |
| extension Factory { | |
| static func make() -> Value { | |
| fatalError("In default static implementation") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| welcome you to the first presidential debate | |
| sponsored by the Commission on Presidential Debates | |
| drafted tonight's format | |
| agreed to by the campaigns | |
| divided into six segments | |
| explore three topic areas tonight | |
| have an open discussion | |
| shared with the commission or the campaigns | |
| we welcome the candidates | |
| cover all the issues of this campaign tonight |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let strA: String? = check ? "hrm" : nil | |
| print(strA) // .None | |
| let str: String = "hrm" | |
| let strB: String? = check ? str : nil | |
| print(strB) // .Some("Awesome Idea.") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // PublicationCenter.swift | |
| // | |
| // Created by Brian King on 5/17/16. | |
| // Copyright © 2016 Raizlabs. All rights reserved. | |
| // | |
| import Foundation | |
| /// PublicationCenter is an NSNotificationCenter style object that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /** | |
| * Build script to generate a type safe wrapper around your projects .xcasset file. | |
| * This will fail your build if you reference an image in your .xcasset file that has | |
| * changed or been removed, as well as provide code completion help for all your images. | |
| * | |
| * Copy this file into a new `Run Phase` in your project, with `/usr/bin/env xcrun swift` | |
| * specified for `Shell`. | |
| * | |
| * Configure the variables below: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| operator infix =~ {} | |
| func =~ (input: String, pattern: String) -> String[]? { | |
| let regex = NSRegularExpression(pattern: pattern, options: .CaseInsensitive, error: nil) | |
| let results = regex.matchesInString(input, | |
| options: nil, | |
| range: NSMakeRange(0, countElements(input)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class FooFun { | |
| @objc | |
| func bat() { | |
| println("bat") | |
| } | |
| } | |
| class Foo :NSObject { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class Foo { | |
| func bar() { | |
| println("Swift Hello, World!") | |
| } | |
| @objc | |
| func baz() { | |
| println("baz") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef enum { | |
| BKSlideDirectionRight = 1 << 0, | |
| BKSlideDirectionLeft = 1 << 1, | |
| BKSlideDirectionUp = 1 << 2, | |
| BKSlideDirectionDown = 1 << 3, | |
| BKSlideDirectionVertical = BKSlideDirectionUp | BKSlideDirectionDown, | |
| BKSlideDirectionHorizontal = BKSlideDirectionLeft | BKSlideDirectionRight | |
| } BKSlideDirection; |