Module Outline

Use the following resources and work with your mentor to master the objectives for this module. Practice by completing the Mini-Project, Project, and Challenges.

Video Challenges

  • Sort the Array

    Using the Playground used in the Group Demo for this objective, sort the array of people by age in ascending order.

    Map an array of ages and sort that array in descending order.

  • App Icon
    • Create an URLSessionDownloadTask to get poster art
    • Display the album art on the View Controller

Stretch Problem

    Failable Initializers

    Example Dictionary:

    let workingDictionary = ["nameKey" : "Derek", "ageKey": 28, "favMovieKey" : "Zoolander"]
    let brokenDictionary = ["nameKey" : "Steve", "ageKey": 2]
    

    PART 1

    1. Make a person class with name, age, and favoriteMovie properties
    2. init the class with a dictionary of type string:anyobject.
    3. Test this to make sure that it works

    PART 2

    1. Read about Failable Initializers
    2. Use a guard statement to handle missing dictionary values
    3. If a value is missing, don't init the person and instead return nil

    ♦ Black Diamond

    Open your Journal project from yesterday. Create a function that will convert your Entry objects into dictionaries. Use this to encode all of the Entry objects stored in your sharedInstance as dictionaries, then print the result.

  • Hint
  • Solution

Guided Project

Project

  • Post Part Two

    Post is a simple global messaging service. Students will review MVC principles and work with NSURLSession, JSON parsing, and closures to build an app that lists and submits posts to a global feed.

    ReadMe

Mastery Review

Module 17 - URLSession (HTTP GET/PUT/POST) init? and dictionaryRepresentation
  • Expand all
  • Collapse all
  • Failable Initializers stretch problem
  • Challenges
    • Sort the Array objective challenge
    • App Icon objective challenge
  • StudentPUTAPI Part Two (PUT/POST) guided project