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
public struct CustomHashable<T>: Hashable { | |
public let value: T | |
public typealias HashCalculator = (CustomHashable<T>, inout Hasher) -> Void | |
public typealias EqualityCalculator = (CustomHashable<T>, CustomHashable<T>) -> Bool | |
public typealias CacheTransformedData = (T) -> Any? | |
private let hashCalculator: HashCalculator | |
private let equalityCalculator: EqualityCalculator |
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
static func buildImageForSize(size:CGSize) -> UIImage? | |
{ | |
if size.height == 0 || size.width == 0 { | |
return .None | |
} | |
var sigRect = CGRectZero | |
sigRect.size = size | |
// The following does NOT work |
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 checkIfFileExpired( fileURL : NSURL ) -> Bool { | |
let fileManager = NSFileManager() | |
if let fileManager.fileExistsAtPath(fileURL) { | |
var error : NSError? = nil | |
if let filePath = fileURL.path, | |
let fileAttr = fileManager.attributesOfItemAtPath(filePath, error: &error), | |
let creationDate = fileAttr[NSFileModificationDate] as? NSDate { | |
return creationDate.isBefore(NSDate.oneDayAgo()) | |
} else { | |
println("problem examining file attributes for \(fileURL): error was \(error)") |
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 | |
// Make constants so the strings can be easily changed. | |
let fizz = "Fizz" | |
let buzz = "Buzz" | |
// Put this its own function just to make different implementations shorter and clearer. | |
func fizzbBuzzDeterminer( candidateNum : Int, isFizz: Bool, isBuzz : Bool ) -> String | |
{ | |
var toPrint :String |