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

MapSwift- lesson 4

leveton
May 15, 2017
27

MapSwift- lesson 4

leveton

May 15, 2017
Tweet

Transcript

  1. retina, retina-HD, pixels and points @1x, @2x, @3x.. You will

    see these suffixes appended to to images. What do they mean? The Asset Catalog will automatically match up images suffixed with @2x and @3x with retina and retina HD respectively: .
  2. Let’s get continue with our class project The final project

    will be a tabbar-based location services app. Here’s how our app’s preview images would look on The App Store:
  3. UITabbarController and UIViewController UITabbarController is a subclass of UIViewController. It

    has an array property with UIViewController elements which are shown along the bottom of the device.
  4. UITabbarController and UIViewController In MSMapViewController, walk the property path from

    self to the tabbar’s viewcontrollers, cmd+click into setViewControllers and read the following comment from Apple: “If the number of view controllers is greater than the number displayable by a tab bar, a "More" navigation controller will automatically be shown.”
  5. UITabbarController and UIViewController Our four UIViewControllers will control views for:

    1) Maps 2) Locations 3) Favorites 4) Settings If you’ve done web development, think of view controllers as the html of an iOS app.
  6. UIWindow, UITabbarController and it’s UIViewControllers This is a 3D image

    screenshot of what our settings view controller will look like by the end of the project. Switch to the lesson 12 branch to see it live.
  7. Communicating between objects 3 standard ways to do this 1)

    Calling a property’s method 2) Using NotificationCenter to broadcast 3) Using delegate methods to respond to events Let’s review all 3…
  8. Notification and NotificationCenter Notification - An object that encapsulates information

    so that it can be broadcast by an NoticationCenter object. NoticiationCenter - broadcasts info to your entire program. *Uses a linked list of observers under the hood.
  9. UserDefaults An in-memory key-value database that persists even when the

    user clears the cache or updates your app. Uses a singleton design pattern under the hood.
  10. UserDefaults Only certain objects can be saved to the defaults

    dictionary. They must conform to NSCoding (look up “conform to NSCoding” to understand what this means) This would crash our app because Car is a custom object that doesn’t conform to NSCoding:
  11. Protocols and delegates A class that conforms to a protocol,

    will implement that protocols methods. The conforming class is the delegate. Think of it like a contract that the delegate signs forcing it to call methods based on an event. For example, people execute a certain protocol when a fire alarm sounds.
  12. Protocols and delegates The delegate pattern may be the most

    important pattern for new Apple developers to master.
  13. UIViewController and UITableView - the most common delegate pairing Seen

    in the majority of iOS apps. Required delegate methods include: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int Your app may crash and your tableview will be useless if you fail to implement these methods.
  14. UIViewController and UITableView - the most common delegate pairing The

    interplay between these two objects is so important that 3 of our 4 view controllers will feature this pair.