Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Soccer League Coordinator in Swift

Scott Pollock
Scott Pollock
4,692 Points

A little stuck on getting multiple values in this collection for the soccer project. Is there any good advice?

I was thinking about using multiple variables and assigning them to a dictionary collection, but I'm having trouble figuring out how to reference the "Key" with multiple variables in the collection. I think I need just a little hint to get some parts of the logic started.

Scott Pollock
Scott Pollock
4,692 Points

created:

var evaGordon: [String: Any] = ["Name": "Eva Gordon", "Height": 45, "Experience": false,"Parent Guardian": "Wendy and Mike Gordon"]

then:

let playerRoster = [joeSmith, jillTanner, billBon, evaGordon, mattGill, kimmyStein, sammyAdams, karlSaygan, suzaneGreenberg, salDali, joeKavalier, benFinkelstein, diegoSoto, chloeAlaska, arnoldWillis, phillipHelm, lesClay, herschelKrustofski]

for each variable but for some reason I'm having issues with [String:Any] in the first variables for the players.

I can't seems to utilize the logic to get the Experienced or Unexperienced into:

//experience unexperience player split var experiencedPlayers: [[String: AnyObject]] = [] var unexperiencedPlayers: [[String: AnyObject]] = []

//experienced unexperienced count var numberOfExperiencedPlayer = experiencedPlayers.count var numberOfUnexperiencedPlayer = unexperiencedPlayers.count

a little stuck at the moment...when I adjust one part the others break, but I feel like I'm getting closer

1 Answer

Ryan Maneo
Ryan Maneo
4,342 Points

Provided all variables are inside of the same Object, they should all be able to be referenced.