The code you are using there looks great. Can you show us how you are using it after that code in the playground? I copy and pasted your code, then used it, and everything is working well. What version of Xcode are you using?

I would have to apologise, since now when I did the whole thing again, it works. Exactly the same code works now. Thanks though for coming back on this.
Since this was actually not a question which should be asked, if you want you can delete the post. Other folks checking out the forum shouldn’t get confused thinking there actually was a compile error here, where there isn’t one.