Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MapSwift - lesson 9

leveton
June 05, 2017
27

MapSwift - lesson 9

leveton

June 05, 2017
Tweet

Transcript

  1. UINavigationController For our favorites view, when a user taps a

    cell, the navigation controller will slide the detail view horizontally onto the UIWindow.
  2. UINavigationController The fact that UINavigationController is a subclass of UIViewController

    but also has a UIViewController is not an uncommon pattern in cocoa.
  3. pushing controllers onto the navigation stack Here is a view

    controller being pushed onto the navigation stack. Compare this to lesson 4 when we presented view controller from the bottom as modals.
  4. Subclassing UITableViewCell When the stock table view cell isn’t good

    enough. We need our cell to have 2 label objects, 2 button objects, and an image view object.
  5. Creating our own delegates and protocols For ‘delete’ and ‘details’

    to work, we need to create our own delegate pattern. We could use didSelectRowAt indexPath like before for one button, but we would still need a delegate to handle the other button.
  6. Why are protocols confusing? Because the delegate is the employee

    and the object that owns the delegate property is the boss, BUT the employee is often a superview of the boss!
  7. Why is the delegate property declaration weak? Recall that if

    it were strong, it would increment delegate’s retain count by 1. Our instance of MSTableViewCell would own the delegate. But in our favorite’s view, we’re assigning self to the delegate.
  8. Why is the delegate property declaration weak? But when we

    created the local variable ‘cell’, we’re creating a strong pointer to that cell. If the cell’s pointer to its delegate were strong, then assigning the view controller to the delegate would create a retain cycle
  9. Map Does some logic on each member of the collection.

    Takes one param that’s a block. The block has one argument.
  10. Filter Creates a new collection based on some condition. Takes

    one param that’s a block. The block has one argument.
  11. Reduce Reduce converts a collection into some primitive (int, float,

    etc). It takes two variables - a starting point and a block. The block takes two variables - a running total and the each element in the collection.
  12. Functional Programming Sorted, map, filter, reduce, flatMap are all copy-on-write,

    so there are no side effects. Objective-C passes a reference.
  13. Functional Programming If your collection has value types or primitives,

    and you copy your collection, the new collection will share storage until it’s mutated.