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 Swift 2.0 Collections and Control Flow Dictionaries Working with Dictionaries

yusuf Dibswazit
yusuf Dibswazit
1,522 Points

help for challenge Tast 3 of 4 ( swift 2.0 collections and controles

var iceCream = [ "CC": "Chocolate Chip", "AP": "Apple Pie", "PB": "Peanut Butter" ] iceCream.updateValue("Rocky Road", forKey:"RR")

// below is the code for: challenge Task 3 of 4

let applePie = Apple Pie ["AP"] // it gives me this : Bummer! Make sure you're retrieving a value from the dictionary rather than assigning a string directly // so i will try another code. this time without assinging a string directly ( which in my mind, i'm thinking it means string= string , nmeaning applePie= Apple Pie) let applePie = ["AP"] // it NOW gives me this: Bummer! Make sure you're assigning the value from the dictionary to a constant named applePie // at this point my knowledge is to do the following: let applePie = // what comes after this?

dictionary.swift
// Enter your code below
var iceCream = [
"CC": "Chocolate Chip",
"AP": "Apple Pie",
"PB": "Peanut Butter"
]
iceCream.updateValue("Rocky Road", forKey:"RR")

// below is the code for: challenge Task 3 of 4

let applePie = Apple Pie ["AP"]
// it gives me this :  Bummer! Make sure you're retrieving a value from the dictionary rather than assigning a string directly
// so i will try another code. this time without assinging a string directly ( which in my mind, i'm thinking it means string= string , nmeaning applePie= Apple Pie)
let  applePie = ["AP"]
// it NOW gives me this:  Bummer! Make sure you're assigning the value from the dictionary to a constant named applePie
// at this point my knowledge is to do the following:
let applePie =
// what comes after this? 

1 Answer

Yusuf,

You almost have it. You need to grab the value from the "iceCream" Array like this:

let applePie = iceCream["AP"]