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 UIKit | |
public extension Sequence { | |
// return true if all elements return true | |
func every<T>(predicate:(T) -> Bool) -> Bool { | |
for item in self { | |
if !predicate(item as! T) { | |
return false | |
} |
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 Foundation | |
public class ThreadUtil : NSObject { | |
// Run a block on the main thread after a specified number of seconds, thanks raywenderlich.com for splaining it so well | |
public static func runOnMainThreadAfterDelay(delaySeconds: Double, closure: () -> ()) { | |
let startTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delaySeconds * Double(NSEC_PER_SEC))) | |
dispatch_after(startTime, dispatch_get_main_queue(), closure) | |
} |
NewerOlder