converted to first chapter 14 example to swift (with Objective-C helper, useful technique)