I've been avoiding the move to Swift because I've been very happy and content with Objective-C. I've recently, for various reasons, decided to make the move to learn Swift by writing a new app in it.
The first class I decided to write takes a delegate. Easy peasy, just write up a protocol using what I've just read in the reference.
And then I went to add 3 optional func's just like I had in the Objective-C version of this class and that when I discovered that if I want to define an optional func in a protocol, I have to make the whole protocol objective-c compliant!
Add to that the fact that the func's in question have a parameter which is an instance of the Swift class I was starting to write, and I then discover that I have to declare that class as being Objective-C compliant as well.
What gives? I thought this was a new, independent language that was open-source, allowing development of compilers for other platforms? How does this work when the language definition involves deep hooks into Apple's legacy language Objective-C? How, on another platform is that supposed to work?
Is the answer, not to use optional func's in Swift? I expected, and knew that there were ways to bridge Swift and Objective-C, but I didn't expect to find that Swift's language is tightly coupled with Objective-C's runtime.
So what do I do now? If I want to teach myself Swift so that my knowledge of the language is a saleable skill for my resume, what are companies that call themselves "Swift" doing for this sort of thing? Do they code in a way to avoid all of these Objective-C hooks? Is that possible? I've only just started on my first class file, so I wonder how many other hurdles like this I'm going to find. I thought Swift was supposed to be easy to learn for beginners. What is a 16yo going to do when they start learning about protocols and optional func's for example?