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.

Objectives

Required Preclass Resources

Lesson Video

Video Challenges

Stretch Problem

    Ternary

    PART 1

    Make an array of 10 Ints Make a function that takes a parameter of Int Array and loops through the array. If the value is below 50, print "low". Otherwise, print "high." Make an array of 10 Ints and test your function by passing it this array to be sure that it works.

    Now add an if statement to your loop so that if the value is divisible by 13 it also prints "didn't learn this one in school," otherwise print "that's easy." NOTE: you may want to create a "print" variable and add to it every time we add a new piece of logic, i.e. let printStatement = "", then start adding to it printStatement = printStatement + "low", etc.

    Add another if statement to your loop so that if the value is greater than the previous value it also prints "getting bigger" otherwise print "it's stopped growing" (for the first value, you can compare it to 0).

    An example of the print statement would be low, that's easy, getting bigger.

    PART 2

    Change your code to use ternary operators (see "Ternary Conditional Operator" in the Swift Programming Guide)

    PART 3

    Create two optional values, one set to nil and one not set to nil, and use “nil coalescing” (also see documentation or the Swift Programming Guide) to unwrap each optional value (in place of if let)

    ♦ Black Diamond

    Write a function called "simplify" that takes a single parameter: An array of integers. Your function should return a new array that is sorted (in ascending order), with all duplicates removed: So for instance, if I passed in: [0, 9, 8, 3, 3, 3, 5, 9, 5, 0]

    Your function would return: [0, 3, 5, 8, 9]

    Do this using the ternary operator instead of a full if statement.

  • Hint
  • Solution

Guided Project

    Journal Core Data

    JournalCoreData has students practice using an NSFetchedResultsController to display information stored in Core Data in a Table View.

Project

  • Task Part Two

    Students will build a simple task tracking app to practice project planning, progress tracking, MVC separation, intermediate table view features, and Core Data.

    ReadMe

Mastery Review

Module 14 - Intermediate Core Data
  • Expand all
  • Collapse all
  • Ternary stretch problem
  • Challenges
  • Journal Core Data guided project