Ports of Apple Sample Code to Swift