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 trialMatthew Daugherty
1,017 PointsTrouble with Key
Hello,
I am having trouble with XCode whenever I try to do the first step in the video.
I am instructed to type in airportCodes["LGA"] in order to isolate that line, but whenever I do, XCode gives me an error and says "Cannot subscript a value of type '[String]' with an index of type 'String'"
It seems like a very simple thing, but I'm confused as to what I'm doing wrong, as I'm typing in exactly what is in the video.
Any help is appreciated, thanks.
1 Answer
Dalisson Figueiredo
7,731 PointsYou should post your code so we can see exactly what you are doing. Anyway see my example:
var airportCodes = ["LGA" : "La Guardia",
"DUB" : "Dublin",
"GIG" : "Galeao"]
airportCodes["LGA"] = "La Guardia International"
print(airportCodes["LGA"])
airportCodes.updateValue("Rio de Janeiro International", forKey: "GIG")
airportCodes.removeValueForKey("DUB")
Matthew Daugherty
1,017 PointsMatthew Daugherty
1,017 PointsI see now it was an issue with my dictionary in the video prior, so it's been taken care of! Thank you for your help!