iOhYes

iOhYes

A podcast by iOS developers for iOS developers, delivering news, tips, and rants for professional iOS/Mac developers, with something for enterprise and indie developers alike.

Hosted by Darryl Thomas, John Sextro, and Nolan O'Brien.



#110: Caveat Apptor

May 18, 2016 at 12:30PM • 1 hour 4 minutes

Discussion

  • Swift 3.0
    • To be available later this year
        * [Winding Down the Swift 3 release - Chris Lattner](http://thread.gmane.org/gmane.comp.lang.swift.evolution/17276)
            * New “blue sky” proposals will be considered for post-3.0 development (~August)
            * Generics features (among other dependencies) are preventing the previously-planned ABI stability
            * ABI stability will come in a later release and is considered of “highest priority”
      
  • CareKit
    • Why use it?
      • enable people to actively manage their own medical conditions through app-based care plans, and symptom and medication monitoring, while sharing insights with care teams and others you trust
      • Examples:
        • Surgery recovery app
        • Depression treatment app
        • High blood pressure treatment app
    • What is it?
      • open source framework
      • can integrate with ResearchKit
      • able to access HealthKit data, when granted permission
    • ((Opinion)) Why the focus from Apple on Health Apps? Is this a legacy from Steve Jobs?
    • Components of CareKit
  • Care Card
  • Symptom and Measurement Tracker
  • Care Plan Store
  • Insights
  • Documents
  • Connect
  • Privacy concerns
    • Downloader beware. Make sure you understand the privacy policy for the app.
    • Make sure the app is from a reputable source

Picks

Darryl

John

  • Start CareKit app for tracking the effectiveness of depression medication


#109: Mistakes Were Made

May 4, 2016 at 11:15AM • 45 minutes

Discussion

Buglife

Buglife.com

  • What is it?
  • What was the motivation?
  • How do we incorporate it into our apps?
  • Pricing
    • Core product is free
    • Planned introduction of paid plans for enterprise teams
    • How did you arrive at this strategy?
  • Who did the voiceover for your demo video?

Creating a 3rd-party service and framework for iOS apps

  • You’re not only the primary engineer but also a PM. What is your process for user research and determining a roadmap?
  • Are there any key (and perhaps unexpected) differences from developing first-party applications?
  • How do you obtain information about framework stability as a third-party? (crashes, logging, etc)

Picks

Dave

Darryl

Nolan

John


#108: Peeling the Onion on Networking

April 20, 2016 at 9:15AM • 1 hour 15 minutes

Discussion

Testing normal networks (aka, not the US)

  • 62.5% of the world’s 3.2 Billion internet users have 2G connections (or worse). That number is growing. LTE speeds aren’t going to catch up for at least a decade if not much longer.
  • When building robust networking between your client apps and your services, the common case should be the default case. AKA: not WiFi and not LTE.
  • Things that help a great deal:
    • Test on 2G and flaky networks
      • Helps to do real world testing in parking garages, elevators and in transit.
      • Simulation will be the highest reproducible ROI way to test
    • Fail fast and accurately. Timeouts play a part in this.
    • Be dynamic with how you handle the network.
      • Slower speeds should have less networking
    • Use modern tech, like HTTP/2
    • Defer, defer, defer (and prioritize)
    • Robustly handle errors
      • If at first you don’t succeed, try again! And again and again. Retry policies can get you from one-9 of success to three-9s very simply.
    • Design your network API in a robust manner!
  • Simulating bad connections:
  • Timeouts

    • List of timeouts:
      • TCP: connection timeout (TLS connection timeout too), SYN timeout, keepalive/idle timeout, retransmission timeout
      • NSURL: request timeout (max time between data being received in response - default is 60 seconds), resource timeout (time for entire transfer to complete - default is 7 days)
      • Custom timeouts: transaction timeouts (time from initiation to completion including redirects and retries), queue timeout (how long can the request be queued without starting before it times), idle timeout (how long can a request do nothing regarding upload or download before timeout)
    • NSURLSession has a problem with scale. Every different configuration setting requires another NSURLSession to be maintained and managed. Timeouts, different default headers, different TLS settings, different cookie settings, different NSURLCache, cellular vs non-cellular
  • Robust API design

    • Transactional APIs
    • Robust error codes (not just HTTP status codes!)
  • Retry policies to the rescue

Picks

Darryl

  • Pain Free Constraints with Layout Anchors - A bit of follow-up from last week’s episode. I felt like John and I were having trouble explaining anchors, and I remembered this article from a few weeks back.

Nolan

Alternative show title suggestions

  • Just remember: You’re wrong
  • Not all requests are made equal
  • Item potency


#107: Hit the TIE Fighter

April 13, 2016 at 8:15AM • 1 hour 17 minutes

Discussion

Auto Layout

  • Stack Views, FTW (Auto Layout without constraints) (New in iOS 9, similar to what’s available in watchOS and NSStackView, which is available from OS X 10.9)
  • UILayoutGuide
    • New in iOS 9
    • Defines a rectangular geometry that can interact with Auto Layout
    • Eliminates the need (in many cases, at least) for views that are included solely for layout purposes (container views, spacing views, etc)
    • Views can still provide a greater degree of encapsulation
    • Provide anchors that can be used to generate constraints
  • Anatomy of constraints
    • The layout of your view hierarchy is defined as a series of linear equations. Each constraint represents a single equation. Your goal is to declare a series of equations that has one and only one possible solution.
    • Two basic types of attributes
  • Size attributes (for example, Height and Width)
  • Location attributes (for example, Leading, Left, and Top)
  • The following rules apply:
    • You cannot constrain a size attribute to a location attribute.
    • You cannot assign constant values to location attributes.
    • You cannot use a nonidentity multiplier (a value other than 1.0) with location attributes.
    • For location attributes, you cannot constrain vertical attributes to horizontal attributes.
    • For location attributes, you cannot constrain Leading or Trailing attributes to Left or Right attributes.
  • Rule of Thumb for clarity
    • Whole number multipliers are favored over fractional multipliers.
  • Positive constants are favored over negative constants.
  • Wherever possible, views should appear in layout order: leading to trailing, top to bottom.
  • Constraint Priorities
    • 1000 is required
    • < 1000 is optional
  • Intrinsic Content Size
    • Content Compression Resistance
    • Content Hugging
  • Debugging Auto Layout
    • Error Types
      • Unsatisfiable Layouts. Your layout has no valid solution.
        • Usually 2 or more required constraints conflict
    • Ambiguous Layouts. Your layout has two or more possible solutions.
        * Need additional constraints
      
      • conflicting optional constraints
    • Logical Errors. There is a bug in your layout logic.
  • Tips and Tricks
    • take advantage of the logs
    • use meaning identifiers on views and constraints
    • Debug > View Debugging > Show Alignment Rectangles

Picks

Darryl

Nolan

John


#106: Push It to the Limit

April 4, 2016 at 8:00PM • 53 minutes

Discussion

Push Notification Overview

  • Notifications
    • Intended for user
    • Certificate required
    • Can be disabled
    • Remote vs. Local
      • Local - schedule by the app on device
        • Best example is Reminders app
        • Schedule by
          • elapsed time or exact time
          • location based
      • Remote - come from your server
  • Actions
    • Interactive Notifications
    • Categories
  • Text Input

    • New type of “Action”
    • Behavior is “.textInput”
  • APNS (Apple Push Notification Service)

    • Device token created by APNS, need to store on server, associated with particular client app
    • Payload must include aps, but can also include custom values, as well
    • Payload “aps dictionary”: alert (string or dictionary), badge, sound, content-available, category
    • Payload alert dictionary: title, body, title-loc-key, title-loc-args, action-loc-key, loc-key, loc-args, launch-image
    • Silent notifications (content-available == 1) wakes your app in the background so that you can fetch data, etc.
    • Feedback service, how to discover tokens that are no longer active
    • Device tokens are 32 bytes, may be increasing to 100 bytes soon
    • New provider API released in 2015
      • HTTP/2
        • notification requests to APNS get a response
        • multiplexed
        • binary
      • Notification requests
        • POST
        • json
      • Notification responses
        • 200 OK
        • 400 BAD REQUEST with json payload and reason
      • Instant Feedback
        • Allows you to learn about inactive tokens in the notification response via 410 status code in the response
      • Simplified Certificate Handling
        • Now one certificate for all push actions
      • Push notifications payload size increased from 2KB to 4KB


#105: Developer Productivity

March 30, 2016 at 10:30AM • 51 minutes

Motivation / Staying Productive

Flow

Mihaly Csikszentmihalyi

Flow theory postulates three conditions that have to be met to achieve a flow state:

  1. One must be involved in an activity with a clear set of goals and progress. This adds direction and structure to the task.
  2. The task at hand must have clear and immediate feedback. This helps the person negotiate any changing demands and allows them to adjust their performance to maintain the flow state.
  3. One must have a good balance between the perceived challenges of the task at hand and their own perceived skills. One must have confidence in one's ability to complete the task at hand.

Clear Distractions

  • What things easily distract you when you need to get work done
  • Make a list of these things
  • Twitter, imgur, reddit, tv, music
  • Clear these distractions
  • Use a distraction free setting
  • Get comfortable
  • Change your setting

Pairing

  • Workout metaphor
  • Hard to slack
  • Intensity
  • Don't have to do it every day

Just 5 minutes

  • I use this technique with my kids for studying
  • 5 minutes doesn't really work for me
  • Instead I say write 5 lines
  • Sunk cost fallacy works in our favor
  • I'm already here. I have something started. I might as well keep going.

Push the peanut forward

  • You don't have to love it
  • You recognize that you just need to make some progress
  • Commit to sit down and get started

Free Writing

  • Used by writer
  • Set a timer, at least 5 minutes
  • Don't use the IDE
  • Don't write actual code, just pseudo code
  • Don't think just let the pseudo code flow

Pomodoro Method

  • Sit down in front of your computer
  • Set a 20 minute timer
  • You must take a 5 minute break
  • The importance of the break, related to exercise

David Burns MD

  • Write down, on a scale of 1 to 10, how satisfied do you think that you will feel by completing the work that you need to do
  • Write down, on a scale of 1 to 10, how painful will it be to do the work
  • Do this before as an estimate and then after recording the actual
  • Keep a running list and refer to it often


#104: Power Struggles

March 10, 2016 at 3:00AM • 45 minutes

Discussion - Energy Efficiency for iOS Apps

Are you telling me I have to worry about my app’s power consumption?

  • This is iOS. I thought Apple was taking care of that for me...right??

What is Energy?

  • Power is an instantaneous measurement of energy at any given point in time
  • Energy is power used over time (Joules measured over watt-hours)
  • Low power used over a long(er) period of time can amount to the same energy expenditure as short bursts of high power (more on this later)

Major sources of energy consumption/power draw

  • Device wake
    • Aside from being powered off, a device in its sleep state is consuming the lowest amount of energy possible
    • Whenever possible, avoid preventing the device from sleeping or forcing it to awaken
    • Use technologies like push and background tasks judiciously
  • CPU Usage
    • An idle CPU uses ~10x the power of a sleeping CPU
    • Just 1% CPU use costs 10% more than idle
    • 10% CPU use costs 200% that of an idle CPU
    • 100% CPU can result in 1000% (10x) power draw compared to idle
  • Networking / Bluetooth
  • Graphics/animation/video
  • Sensors
    • Location (Wi-Fi/GPS)
    • Accelerometer
    • Gyroscope
    • Magnetometer
  • Disk IO. Use batch operation whenever possible

Mitigating energy costs

  • Batching, Batching, Batching
    • Operations have a dynamic and fixed energy cost
      • Fixed cost represents the energy used while the device is waiting to enter an idle state
      • The same amount of work, performed across multiple threads, can have a significantly lower total energy cost compared against single-threaded work requiring a longer time to execute
    • Network and other inter-device (BT, for example) operations require radios to be powered up. Avoid continuous communications and state polling, batching operations whenever possible
    • Defer any operations that aren’t time-sensitive to time that the app will be otherwise active (take advantage of fixed cost you’re already having to pay)
  • Prioritize operations using Quality of Service Classes (iOS 8+)
    • Classes
      • User-interactive
      • User-initiated
      • Utility
      • Background
    • Can be set on both NSOperationQueue and individual NSOperation objects
    • GCD queues can be created with QOS class attributes
  • Use timers efficiently, or better yet, avoid them
    • GCD provides mechanisms you can use instead of timers, for example dispatch_block_wait()
    • If you must use timers (not just NSTimer: basically anything that takes a time interval as a deadline), take advantage of APIs that allow for timer coalescing using tolerances.
  • Minimize I/O
  • React to Low Power Mode (iOS 9)
    • NSProcessInfoPowerStateDidChangeNotification
    • [[NSProcessInfo processInfo] isLowPowerModeEnabled]

Instruments to the Rescue

  • Energy Diagnostics Logging

Other Resources

Picks

John

Darryl

Alternative show title suggestions

  • Power Draw
  • Contribute to Sleep
  • Don’t write an app
  • (You should) Get off of the main thread
  • They DID bone it
  • I ripped them off


#103: Don’t Hate Us, Nolan

March 2, 2016 at 10:00AM • 54 minutes

Discussion

Pushing info to clients

  • Long Polling
    • Client sends request to server, waits for response or timeouts (Loop)
    • Can send and receive information, but not full-duplex
    • iOS Implementation
      • NSURLConnection sendSynchronousRequest
    • Common uses
      • Fallback from Websockets and SSE when streams are unreliable or impractical
  • HTTP Streams
    • Can only push information to your client
    • If you need to send info back to server use standard rest approach
    • Transported over simple HTTP
    • Built in support for re-connection and event-id
    • iOS Implementation
      • Server Sent Events (SSE)
      • NSURLSession, NSInputStream, NSSteamEvent
      • Setup the connection
      • Implement code to handleEvents from the input stream
    • Common uses
      • Stock ticker streaming
      • “Status” feed updating
      • Push Notifications
  • Websockets
    • Designed to overcome many of the pitfalls/shortcomings described in RFC 6202
    • Standardized by IETF (Internet Engineering Task Force) in 2011
    • Can send and receive information (full-duplex pipe)
    • Protocol based on TCP
    • Uses HTTP only for initial handshake, while leveraging existing HTTP infrastructure
    • iOS Implementation
      • CFStreamCreatePairWithSocketToHost takes url, read and write stream
      • Cast read and write stream to NSInputStream and NSOutputStream, respectively
      • Set delegate for input and output streams
      • Schedule both in a run loop (Can do without but will block the execution of other code)
      • Open connection
      • Write code to handleEvents from the input stream
      • Implement message sending via the output stream
    • Server considerations
      • Not as easy to get started with as a generic web server
      • Buy one, borrow one or build one
    • Common uses
      • Chat
      • Player vs. Player games
      • Real time interactions
  • Popular Abstractions/Frameworks

At-a-glance Comparison

Websockets SSE Long Polling
Client Performance Best Best Worst
Server Performance Best Worst Worst
Complexity Highest Lowest Mid
When to Use 2-way messaging Push to Client Just getting started

Picks

Darryl

John

Alternative show title suggestions

  • Uncanny valley
  • The cooker's always on
  • Canonical Framing Technique


#102: At Least Somebody's Delivering!

February 24, 2016 at 10:00AM • 4 minutes

John and Darryl compliment each other and congratulate Nolan and Chad.

Discussion

  • Congratulations to the O'Brien family on the birth of Evelyn Jane!

  • Congratulations to Chad and Kim Etzel, who are expecting in August!


#101: HTTP/2 101

February 11, 2016 at 1:45PM • 1 hour 11 minutes

Discussion

HTTP/1.1 review

  • Widespread adoption in 1996 with full standard in 1997 RFC 2068 and later replaced with one in 1999 RFC 2616
  • Request (URL, method, headers, body) & Response (status code, headers, body)
  • Inherently async
  • Built for HyperText, makes it have problems
    • Head of line blocking
      • combining payloads to 1 response
      • multiple connections (Connection: Keep-Alive vs Close)
      • HTTP Pipelining
    • No cancellation, have to tear down connection
    • No prioritization, round robin over connections
  • iOS/Mac
    • NSURLRequest (NSHTTPURLRequest) and NSURLResponse (NSHTTPURLResponse)
    • NSURLConnection and NSURLSession

HTTP/2

  • Started by Google with SPDY (2012 - 2016), latest is SPDY/3.1
  • HTTP/2 is a binary protocol, where 1 and 1.1 are text
  • Previous episode on SPDY with M Schore
  • Reached standard in 2015 with RFC 7540 and adopted by Apple with iOS 9, Mac OS X 10.11
  • Resolves many issues with new features:
    • multiplexing (helps with head of line problem in HTTP/1.1)
      • cancellation
      • header compression
        • Always there
        • plain text, optimal for compression
      • dynamic prioritization
  • be responsible, set lower priority when possible
    • not guaranteed that the server will prioritize because it is optional in HTTP/2 spec
    • push responses (Nolan’s not a fan)
      • not supported by Apple
  • Upgrade to HTTP/2 dynamically with Upgrade Header or ALPN

Picks

Nolan

Darryl

John

Jason