I'm trying to write my first app in swift on Xcode and I'm stuck!!
I have a dictionary - I've shuffled it - and now want to print the values to different labels in the order they have been shuffled in.
I'll give an example and try and explain the outcome I am expecting.
label1 : UILabel!
label2 : UILabel! label3 : UILabel! label4 : UILabel!
animals = [1:"cat", 2:"dog", 3:"snake", 4:"Mouse"]
shuffled animals = animals.Shuffled
// - expecting output like [2:"dog, 4:"mouse", 1:"cat", 3:"snake"
I tried... `Label1.text =shuffledanimals[0] Label2.text = shuffledAnimals[1] Label3.text = shuffledAnimals[2] Label4.text = shuffledAnimals[3]'
// like the index of the dictionary.. (this didn't work) not sure why??
Also is there a way to put this in a loop to make it cleaner ?
Any help will be appreciated .. Thanks
Please note.. I would like to use a dictionary over an array as I have other needs for the keys.. and it has 40 pairs in so my method is not practical at all