Stuart Breckenridge

The Measurement Type

The new Measurement type1 is a hugely helpful addition to the Foundation framework. It allows for conversion amongst many different measurements:

  • Acceleration
  • Angle
  • Area
  • Concentration Mass
  • Dispersion
  • Duration
  • Electric Charge
  • Electric Current
  • Electric Potential Difference
  • Electric Resistance
  • Energy
  • Frequency
  • Fuel Efficiency
  • Length
  • Illuminance
  • Mass
  • Power
  • Pressure
  • Speed
  • Temperature
  • Volume

Usage is simple:

var mLs = Measurement(value: 125, unit: UnitVolume.milliliters) // 125 mL
var flOz = mLs.converted(to: UnitVolume.fluidOunces) // 4.2267 fl oz

Apple has provided excellent documentation on how to subclass the Dimension type, and on extending existing Dimension types. My quick experiment was to create a new UnitUKCurrency type:

class UnitUKCurrency: Dimension {
    static let pence = UnitUKCurrency(symbol: "pence", converter: UnitConverterLinear(coefficient: 1.0))
    static let pounds = UnitUKCurrency(symbol: "pounds", converter: UnitConverterLinear(coefficient: 100.00))
    override static func baseUnit() -> UnitUKCurrency {
        return self.pence

Which, in use, looks like this:

let pennies = Measurement(value: 1234.0, unit: UnitUKCurrency.pence) // 1234.0 pence
let poundage = pennies.converted(to: UnitUKCurrency.pounds) // 12.34 pounds

If only Measurement was around for v1.2 of Baby’s Milk!

  1. The NSMeasurement class in Objective-C. ↩︎

App Store Changes


We’re introducing exciting new capabilities and tools designed to help grow your app’s business and engage with new and existing customers on the App Store.

Search Ads
Search Ads is an efficient and easy way for you to promote your app directly within the U.S. App Store search results, helping customers discover or reengage with your app, while respecting their privacy. Starting this summer, you’ll be able to participate in the Search Ads beta and see the ads in action.

Subscription Enhancements
We’re opening auto-renewable subscriptions to all app tags including games, increasing developer revenue for eligible subscriptions after one year, providing greater pricing flexibility, and more.

Search Ads has been rumoured for a while and their implementation seems to be a fair to users from a privacy standpoint and to developers—both large and indie—from an ad pricing standpoint. Subscription changes open up the possibility of free trials—something developers have been demanding for a long, long time!

In addition, App Store review times have been cut to 48 hours in 90% of cases. I can vouch for this, one my apps was submitted on Saturday and was approved within a day.

UIAlertController Preferred Action

In a scenario where your UIAlertController alerts only have .Default actions, how do you add emphasis to what should be considered the preferred action of the user? Prior to iOS 9, this wasn’t possible without using a .Cancel action type, or creating your UIAlertController-like class from scratch. Enter preferredAction.

Let’s look at an example:

let alert = UIAlertController(title: "Send Error", message: "Your email failed to send.", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Try Again", style: .Default, handler: nil))
alert.addAction(UIAlertAction(title: "Remind Me Later", style: .Default, handler: nil))
alert.addAction(UIAlertAction(title: "Delete Draft", style: .Destructive, handler: nil))
presentViewController(alert, animated: true, completion: nil)

The above code will present a UIAlertController as follows:

UIAlertController Example 1

There is no obvious default action being highlighted to the user. To set a preferredAction, you just add this piece of code prior to presentViewController...:

alert.preferredAction = alert.actions[1] // Remind Me Later is at index 1 in the actions array.

Voila! Emphasis has been added to what should be considered as the preferred action.

UIAlertController Example 1

Microsoft Exiting Consumer Phone Market

Peter Bright (via ArsTechnica):

Microsoft bought Nokia’s Devices and Services business in 2013 for $7.1 billion. In July last year, Microsoft laid off 7,800 of the staff from that acquisition and took an impairment charge of $7.6 billion. The remaining feature phone portion of the business was sold off last week for $350 million. With today’s announcement, the smartphone hardware business is being all but wiped out. There will be one last impairment charge of approximately $950 million, of which $200 million is severance pay.

What I said in July 2015 following the restructure announcement:

It’s hard not to see this as both a failed investment and the beginning of the end for Microsoft built Windows Phone hardware.

The acquisition of Nokia was a reactionary one, a last ditch attempt from Microsoft at remaining relevant in the hardware market. But it was never going to pan out: Lumia devices—nice though they were—weren’t selling well and Microsoft’s mobile platform had minuscule market share.

That this has happened is terrible for those involved.


Update: SLComposable is available on Cocoapods:
pod "SLComposable"

I’m in the process of rebuilding an old demo app I created three years ago for the Social framework. In that demo app I created individual instance methods for creating an SLComposeViewController with initial text, with initial text and an image, for each social network, and so on.

With the rebuild, I’ve gone about it a different way. I’ve created a protocol, SLComposable, which defines one method:

func composePost(text text:String?, image:UIImage?, url:NSURL?, network: SLComposableServiceType)

That’s it. One method for all social networks supported on iOS.

It’s been extended to UIViewController with an implementation that will check if posting to the specified social network is allowed, and if it isn’t it will present an UIAlertController to the user.

The full gist is below: