-
Install Swift development toolchain: https://swift.org/getting-started/#installing-swift
-
Check install successful by running
swift --version
-
Check Package Manager install
swift build --version
-
Create Command-Line Project
-
Put project aside for now
-
In terminal, cd to project directory
-
Create
Source/
folder and create amain.swift
file -
main.swift
is a ruse to get the package manager to build, put onlyprint("Build Successful")
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
extension SequenceType { | |
func ip_splitFilter(@noescape predicate: Generator.Element throws -> Bool) rethrows -> (passed: [Generator.Element], failed: [Generator.Element]) { | |
var passed: [Generator.Element] = [] | |
var failed: [Generator.Element] = [] | |
try forEach { element in | |
if try predicate(element) { | |
passed.append(element) | |
} else { | |
failed.append(element) |
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
xcrun simctl erase all |
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
public struct Weak<T where T : AnyObject> { | |
public weak var value: T? | |
public init(_ value: T) { | |
self.value = value | |
} | |
} | |
public protocol Multicast : class { | |
typealias Delegate: AnyObject | |
var delegateReferences: [Weak<Delegate>] { get set } |
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
internal extension SequenceType { | |
func ip_splitFilter(@noescape filter: (Generator.Element) throws -> Bool) rethrows -> (passed: [Generator.Element], failed: [Generator.Element]) { | |
var passed: [Generator.Element] = [] | |
var failed: [Generator.Element] = [] | |
try forEach { | |
if try filter($0) { | |
passed.append($0) | |
} else { | |
failed.append($0) | |
} |
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
extension UITableView { | |
func registerCell<T : UITableViewCell>(_: T.Type, identifier: String = T.identifier) { | |
if let nib = T.nib { | |
registerNib(nib, forCellReuseIdentifier: identifier) | |
} else { | |
registerClass(T.self, forCellReuseIdentifier: identifier) | |
} | |
} | |
func registerHeader<T: UITableViewHeaderFooterView>(_: T.Type, identifier: String = T.identifier) { |
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
extension UIView { | |
class func fromNib(nibNameOrNil: String? = nil) -> Self { | |
return fromNib(nibNameOrNil, type: self) | |
} | |
class func fromNib<T : UIView>(nibNameOrNil: String? = nil, type: T.Type) -> T { | |
let v: T? = fromNib(nibNameOrNil) | |
return v! | |
} | |
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 AVFoundation | |
protocol SoundFile { | |
var soundFile: String { get } | |
} | |
extension SoundFile { | |
private var nameComponents: [String] { | |
return soundFile.componentsSeparatedByString(".") |
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
enum ColorDescriptor { | |
case PatternImage(imageName: String) | |
case RGB(r: Int, g: Int, b: Int, a: Int) | |
} | |
extension ColorDescriptor : StringLiteralConvertible, RawRepresentable, Equatable { | |
typealias RawValue = StringLiteralType | |
typealias ExtendedGraphemeClusterLiteralType = StringLiteralType | |
typealias UnicodeScalarLiteralType = StringLiteralType | |
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
enum SortOrder { | |
case Ascending, Descending, Same | |
} | |
extension Array { | |
typealias Sorter = (Element, Element) -> SortOrder | |
func sortWithPriorities(sorters: Sorter...) -> Array { | |
return sort { (left, right) -> Bool in | |
for sorter in sorters { | |
switch sorter(left, right) { |