My goal with this code is to iterate through a dictionary where the keys are a specific college and the values of those keys are the college colors. When a user chooses their college by typing it into a textfield, the background changes to their college colors. When I used just one color iterating through the dictionary worked flawlessly but now that I have introduced a secondary color my code keeps breaking with the error "For-in loop requires '[UIColor]' to conform to 'Sequence'", here is my code. I would appreciate any help
For my dictionary I used Color Literal to easily choose a color:
var collegeDict = ["UCLA": [#colorLiteral(red: 0.2196078449, green: 0.007843137719, blue: 0.8549019694, alpha: 1), #colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)], "Stanford": [#colorLiteral(red: 0.3098039329, green: 0.01568627544, blue: 0.1294117719, alpha: 1), #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)]]
This is the iterator where the error appears:
@IBAction func Button1Pressed(_ sender: Any) {
for (key, colors) in collegeDict {
for (primaryColor, secondaryColor) in colors {
if collegeName == textField1.text {
self.View1.backgroundColor = primaryColor
self.Button1.backgroundColor = primaryColor