Serpent
Serpent copied to clipboard
Swift array with Typed Swift enum causes crash when Encoding
enum Attribute: String { case one = "15" case two = "19" case three = "" }
struct MyStructType { var myArray = [Attribute.one] }
extension MyStructType: Serializable { init(dictionary: NSDictionary?) { myArray <== (self, dictionary, "myArray") }
func encodableRepresentation() -> NSCoding {
let dict = NSMutableDictionary()
(dict, "myArray") <== myArray // myArray.map({ $0.encodableRepresentation() }) seems to fix it
return dict
}
}
func shouldTriggerCrash() { let theInstance = MyStructType() Cashier.defaultCache().setSerializable(theInstance, forKey: rideContainerCacheKey)//Crashes }