Saurabh 😎

WWDC 2018: Adding Delight to Your iOS App

Six main topics: External displays, Layout-driven UI, Fast launch, Smooth scrolling, Continuity/Handoff, Debugging

External Display Support

Show private information on device display, public information on external one

Don't show UI controls on external displays since they're not interactive

Check UIScreen.screens.count > 1 for external display and subscribe to UIScreen screen notifications

Layout-Driven UI


For animations, after you make a state change, call self.layoutIfNeeded() in an animation block with .beginFromCurrentState - the animations will happen "automatically" as you make state updates

Fast Launch

Anatomy of a launch:

  1. Process Forking
  2. Dynamic Linking
  1. UI Construction
    • Return quickly from app delegate methods
    • Avoid reading very large data sets and avoid any disk writes at all
  2. First Frame
    • Only prepare the UI you need and lazily load everything else
    • Don't bring in views that are initially hidden (load them lazily instead before they become visible)
  3. Extended Launch Actions
    • Background work you kicked off during launch to load initial app state
    • App is responsive but not usable
    • Use clear loading animation for slow network conditions

Measure launch time continuously, ideally after every commit

Smooth Scrolling

2 reasons for dropped frames:

  1. Too much computation
  1. Too much graphics compositing

Finds peer devices that are signed in to same iCloud account

Does not require Internet connection since relies on peer-to-peer

Main API is NSUserActivity
Also implemented for free with UIDocument/NSDocument

Use continuationStreams for sharing arbitrary data that won't fit in basic activity object

Set webpageURL to transfer from native app to web app

Can also do web browser to native app using associated-domains entitlement

See WWDC 2014: Adopting Handoff on iOS and OS X


Debugging mindset:

Useful debugging methods:
-[UIView recursiveDescription]
-[UIView _parentDescription] (to view everything above the view)
+[UIViewController _printHierarchy]

settings set target.language objective-c to put debugger in Objective-C mode

Use LLDB for debugging state issues

Memory debugging: