finished converting save-and-restore examples from chapter 6 to swift