I'm trying to use the brand new Sift Chart framework, and the chartForegroundStyleScale function takes a KeyValuePairs as the argument. I tried supplying a Dictionary (of [String:Color], but I get the error Cannot convert value of type '[String : Color]' to expected argument type 'KeyValuePairs<DataValue, S>'.
Ok so fair enough, I need to convert the Dictionary to a KeyValuePair. I tried creating the KVP the same way I created the Dictionary, but this doesn't work. I loop through the appropriate array and build a dictionary, but this doesn't work with a KVP as you cannot modify a KVP once it's created. I also need to add around 40 Keys and Pairs to the item, not a single one.
I tried creating a KVP from the dictionary like this
But this fails with the error Cannot convert value of type '[String : Color]' to expected argument type '(Key, Value)'
All the tutorials I find involve typing out and hard coding the KVP data, which isn't possible for me, as the data will be different each time the app opens. So how do I generate a KVP?
Ok so fair enough, I need to convert the Dictionary to a KeyValuePair. I tried creating the KVP the same way I created the Dictionary, but this doesn't work. I loop through the appropriate array and build a dictionary, but this doesn't work with a KVP as you cannot modify a KVP once it's created. I also need to add around 40 Keys and Pairs to the item, not a single one.
I tried creating a KVP from the dictionary like this
Swift:
let myKVP = KeyValuePairs(dictionaryLiteral: myDictionary)
But this fails with the error Cannot convert value of type '[String : Color]' to expected argument type '(Key, Value)'
All the tutorials I find involve typing out and hard coding the KVP data, which isn't possible for me, as the data will be different each time the app opens. So how do I generate a KVP?