Skip to content

Instantly share code, notes, and snippets.

Nate Armstrong armstrongnate

Block or report user

Report or block armstrongnate

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active Aug 1, 2019
Scheduled NSTimer with a Swift closure
View NSTimer+Closure.swift
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@tjw
tjw / protocol-type-member.swift
Last active Aug 29, 2015
Can't access members of protocol types
View protocol-type-member.swift
public protocol MeasurementUnit {
// If we have one of this unit, how many millimeters is it?
class var asMillimeters: Double { get }
}
public class Inch : MeasurementUnit {
public class var asMillimeters: Double {
get {
return 25.4
}
}
@prrane
prrane / ReadAddressBook.swift
Created Sep 4, 2014
Swift: Get contact emails from AddressBook
View ReadAddressBook.swift
// based on : http://stackoverflow.com/questions/24752627/accessing-ios-address-book-with-swift-array-count-of-zero
// http://stackoverflow.com/questions/24752627/accessing-ios-address-book-with-swift-array-count-of-zero
class func extractABAddressBookRef(abRef: Unmanaged<ABAddressBookRef>!) -> ABAddressBookRef? {
if let ab = abRef {
return Unmanaged<NSObject>.fromOpaque(ab.toOpaque()).takeUnretainedValue()
}
return nil
}
@staltz
staltz / introrx.md
Last active Feb 21, 2020
The introduction to Reactive Programming you've been missing
View introrx.md
View ArrayHelpers.swift
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
You can’t perform that action at this time.