Adapted for Swift example program