Got the Swift code somewhat working.