Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Swift array with Typed Swift enum causes crash when Encoding #163

Open
jakobmygind opened this issue Aug 31, 2017 · 0 comments
Open

Swift array with Typed Swift enum causes crash when Encoding #163

jakobmygind opened this issue Aug 31, 2017 · 0 comments

Comments

@jakobmygind
Copy link

jakobmygind commented Aug 31, 2017

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
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant