'Saving an Array<Color>

I have an array that needs to be formatted as Array. I use the code below to save it throughout my program.

var ScheduledStatusD:Array<Color> {
    get {
        // Get the standard UserDefaults as "defaults"
        let defaults = UserDefaults.standard

      return defaults.stringArray(forKey: "ScheduledStatusD") ?? [Color.gray]
    }
    set (newValue) {
        // Get the standard UserDefaults as "defaults"
        let defaults = UserDefaults.standard

        defaults.set(newValue, forKey: "ScheduledStatusD")
    }
}

My problem is as followed:

Cannot convert value of type '[String]?' to expected argument type '[Color]?'

I've tried change the text .stringArray to .array or .mutableArray, but more problems arose from that. Any solutions?

FYI, the goal here is to have a dynamically stored color array.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source