This file contains 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
# Xcode | |
# | |
build/ | |
*.pbxuser | |
!default.pbxuser | |
*.mode1v3 | |
!default.mode1v3 | |
*.mode2v3 | |
!default.mode2v3 | |
*.perspectivev3 |
This file contains 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
func ReverseAsync<ReturnType>() -> (completionHandler: ReturnType -> Void, complete: () -> ReturnType) { | |
var value: Optional<ReturnType> = .None | |
let semaphore: dispatch_semaphore_t = dispatch_semaphore_create(0) | |
return ( | |
completionHandler: { v in | |
value = .Some(v) | |
dispatch_semaphore_signal(semaphore) | |
}, | |
complete: { |
This file contains 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 NSString { | |
static func ConvertIANACharSetNameToEncoding(name: String) -> NSStringEncoding? { | |
let cf_encoding = CFStringConvertIANACharSetNameToEncoding(name) | |
guard cf_encoding != kCFStringEncodingInvalidId else { | |
return nil | |
} | |
return CFStringConvertEncodingToNSStringEncoding(cf_encoding) | |
} |
This file contains 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
prefix operator !! {} | |
prefix operator ?? {} | |
prefix func !!<T, U>(rhs: T) -> U { | |
return rhs as! U | |
} | |
prefix func !!<T, U>(rhs: T) -> U! { | |
return rhs as! U | |
} | |
prefix func ??<T, U>(rhs: T) -> U? { |
This file contains 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 Swift | |
import Foundation | |
extension String { | |
/// WARNING: Unless `paths.isEmpty`, the resultant String is always backed by NSString storage. | |
init(basePath: String, paths: [String]) { | |
guard paths.count > 0 else { | |
self = basePath; return | |
} | |
This file contains 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
// Tested using Swift 2.2 / Xcode 7.3 | |
import Swift | |
// A function and initializer with 2 parameters of explicit types. | |
func stringTuple(_ lhs: String, _ rhs: String) { | |
print("\(lhs), \(rhs)") | |
} | |
struct StringTuple { | |
init(_ lhs: String, _ rhs: String) { |
This file contains 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 protocol Foundation.NSObjectProtocol | |
/// The minimum requirements for bridging conforming Swift "named types" | |
/// into a representable Objective-C type, i.e. a subclass of NSObject. | |
/// | |
/// Note that implementing the direct descendents of `ObjCBridgeable` | |
/// provides automatic conformance to `_ObjectiveCBridgeable`. | |
protocol ObjCBridgeable: _ObjectiveCBridgeable { | |
// Provides code-completion since the latter is hidden, and provides |
This file contains 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
// Sam's PRNG "proxy" for client-side JS, which generates random `UInt32`'s. | |
// Attempts to resolve the window's Crypto object and use its getRandomValues | |
// function if available, otherwise provides a cryptographically insecure PRN | |
// based on combining the current time and Math.random(). | |
// | |
// Note: if any truthy argument is provided, the Fallback impl. will be used. | |
// otherwise, attempts to use the Window's Crypto object if possible. | |
// Usage: | |
/// var prng = SMPRNG(); | |
/// var uint = prng.next(); |
This file contains 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 UINib { | |
static func Build<View: UIView>(nibName: String? = nil, bundle: NSBundle? = nil) -> View { | |
let typeName = String(Mirror(reflecting: View).subjectType) | |
let nibName: String = nibName ?? typeName | |
let nib = UINib(nibName: nibName, bundle: bundle) | |
for object in nib.instantiateWithOwner(nil, options: nil) { | |
if let view = object as? View { | |
return view |
This file contains 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
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
outline: 0; | |
font-size: 62.5%; | |
vertical-align: baseline; | |
OlderNewer