Serpent icon indicating copy to clipboard operation
Serpent copied to clipboard

Swift array with Typed Swift enum causes crash when Encoding

Open jakobmygind opened this issue 7 years ago • 0 comments

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 }

jakobmygind avatar Aug 31 '17 10:08 jakobmygind