Initial port of iOS sample code.