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 Build a Playlist Browser with Swift Building the Music Library and Playlist Models Creating a Data Model

Build a Playlist Browser with Swift, Stage 3 - Creating a Data Model

This is the challenge:

We need to add the first chocolate to our box. Create a stored property named caramelDelight. To this dictionary add a key named flavor that stores a value named caramel to the caramelDelight dictionary to initialize it.

First we need to create a stored property what I did (not sure if let or var)

Secondly we need to add a key to this dictionary. What dictionary? I don't fully understand the question and everything I've tried is not accepted. Stuck, please help

ChocolateBox.swift
struct ChocolateBox {

    let caramelDelight
}

3 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Floris de Rijke !

Challenge Task 2 of 2 "We need to add the first chocolate to our box. Create a stored property named caramelDelight. To this dictionary add a key named flavor that stores a value named caramel to the caramelDelight dictionary to initialize it."

...wants you to just build a stored property within this struct and initialize it with a small dictionary: "flavor" as key and "caramel" as value leads to ["flavor": "caramel"]. As the value of a stored property might change over time we will use var:

struct ChocolateBox {
   var caramelDelight = ["flavor": "caramel"]
}

Thanks so much Holger! It actually makes sense now.

As a reminder, never use single quote to initialise strings in Swift.... Always use double quotes i.e var treeHouse = "I Love Swift"

Richard Price
Richard Price
2,050 Points

the challenges IMO opinion are tedious and annoying as your constantly 2nd guessing yourself the errors you get back are vague its so disheartening to get to the end of a stage where you felt you learnt so much and realise that you don't understand the question. Ridiculas

I totally agree with you Richard.

In my opinion these challenges should be the heart of the course en should be structured as following:

  • 1. One or two easy challenges in 5 or more steps that just repeat pieces of the course for practice.
  • 2. A more challenging challenge with lots of steps and good "debugging" so you know what it is you're doing wrong.
  • 3. A (very) difficult challenge whit lots of steps (checkpoints) and possible help as to really hardcode the course material in your brain.

Also overall I miss an explanation of the how and why sometimes, which results in being able to replicate but not in being able to divert much. Also lots of "normal" functionality has not been discussed at all, for example table views and feeding them from a dictionary or array.

I understand that Swift is a fairly new language but since the principles are basically the same as Objective-C as I understand, I would have hoped to be able to program a basic app of my own after this course. Thus far I'm only able to explain fairly detailed how I want it to a programmer.

John Stephanites
John Stephanites
2,007 Points

I like the challenges but think the debugging is less than desired. On the other hand the debugging does mimic the compiler in Xcode!