Code Monkey home page Code Monkey logo

objc-dictionary-ice-cream's Introduction

Dictionary Basics: Ice Cream

Objectives

  1. Practice creating and using a dictionary.
  2. Write methods to interpret the information in a dictionary.
  3. Practice converting to a mutable dictionary and modifying it programmatically.

Introduction

Some of the instructors are planning a summer ice cream party. Mark has collected some information on everyone's favorite ice cream flavors (including his own), but he needs help analyzing the list to know how much of each flavor to buy!

Joe likes Peanut Butter and Chocolate
Tim wants Natural Vanilla
Sophie loves Mexican Chocolate
Deniz only likes Natural Vanilla
Tom will eat Mexican Chocolate
Jim never answered so he's getting Natural Vanilla
Mark — Cookies 'n Cream duh

Instructions

  1. Open the *.xcworkspace file and without looking at the tests just yet, navigate to the FISAppDelegate.h header file and declare two methods:
  • namesForIceCream: which takes an NSString argument iceCream and returns an NSArray object.
  • countsOfIceCream: which takes an NSDictionary argument iceCreamByName and returns an NSDictionary object.
  1. In the FISAppDelegate.m implementation file, use autocomplete to define the method bodies to return nil. At the start of the namesForIceCream: method, translate Mark's notes into an NSDictionary with each name as a key with that person's preferred ice cream flavor as the associated value.

  2. When you're done, check your work by looking at the iceCreamByName dictionary in the FISAppDelegateSpec test file. Your dictionary's key-value pairs should match it exactly, but don't just copy/paste it—really try to compose the dictionary yourself. Run the tests now to see that they fail.

  3. Finish the namesForIceCream: method body to return an array of the names of everyone who likes the ice cream flavor submitted in the string argument. For example, "Mexican Chocolate" should return an array with "Sophie" and "Tom".

  4. Write the countsOfIceCream body which returns a dictionary of the number (value) of people who like each flavor of ice cream (key). Look at the countsByIceCream dictionary in the FISAppDelegateSpec file to better understand what the test is expecting.
    Hint: Try using the namesForIceCream: method that you just wrote to get a list of names for each ice cream flavor by calling it on self. This method returns an array of names which you can then count. Remember that you have to convert integer values to NSNumber in order to store them in a collection.

View Dictionary Basics: Ice Cream on Learn.co and start learning to code for free.

objc-dictionary-ice-cream's People

Contributors

ipc103 avatar markedwardmurray avatar sarogers avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kenpcjr

objc-dictionary-ice-cream's Issues

Tests for the first method do not check for exclusion

@AnnJohn Just troubleshooted a student's solution that was returning an array containing all seven names from the first method, which caused a test on the second method to fail, but the tests for the first method should be rewritten to account for this case.

Local Test

Hi, I have a problem running local tests. It's not the first time I'm trying to resolve the problem. Tests pass in XCode but learn.co doesn't recognize it as a result a lesson stays unfinished. Anyway to fix the issue? Thanks!

Dictionaries and Dictionary Basic Practice

I struggled with the coding the methods in this section. After several hours and reviewing the code and reading online materials (stack overflow, rypress, etc) I still could not independently resolve the challenges and had to resort to the ‘solutions’ branch on github.

Perhap more explanation in the tutorial or a more graduated set of coding exercises would do the trick. The NSDictionary data structure seems important so perhaps more time should be devoted to it.

needs clearer instructions

Would be helpful to describe what the methods will do upfront, before you break down the step by step process. I had trouble thinking about what to name the arguments that I would give my methods in their definitions because I wasn't 100% on what I wanted my methods to eventually do.

Second method was tough, could have used some more hand-holding/hints.

@markedwardmurray

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.