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
/* | |
Use with Dictionary data | |
let object:DecodableType? = DecodableType.create(dictionaryData) | |
*/ | |
extension Decodable { | |
static func create(object: Any) -> Self? { | |
guard let dataDict = object as? [String: Any] else { return nil } |
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
/* | |
//Extended Protocol which allows decoding NSManagedObjects using swift4 Codable Protocol. | |
//Requires the convenience initializer implementation as follows | |
public final class City: NSManagedObject, ManagedObjectCodable { | |
convenience public init(from decoder: Decoder) throws { | |
// Get Context from decoder | |
guard let context = decoder.userInfo[.context] as? NSManagedObjectContext else { fatalError("No Managed Object Context!") } |
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 quicksort<T: Comparable>(var list: T[]) -> T[] { | |
if list.count <= 1 { | |
return list | |
} | |
let pivot = list[0] | |
var smallerList = T[]() | |
var equalList = T[]() | |
var biggerList = T[]() |