Bridging Swift and Objective-C
WHAT'S IN THIS CHAPTER
- Organizing Swift code with namespaces
- Packaging Swift code into modules
- Using Swift classes in Objective-C
- Calling Objective-C code from Swift
- Calling C code from Swift
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
Swift incorporates a lot of modern language features, bringing both the iOS and OS X platforms into the twenty-first century and alleviating some of the headaches programmers had when working with Objective-C. However, because both operating systems have a strong heritage rooted in C and Objective-C, it is likely that you will have to work with code written in these languages at some point. This chapter shows some of the key features that allow Swift to interoperate with C and Objective-C, including namespaces, modules, and the functionality that bridges Swift to these older languages.
THE SUCCESSOR TO OBJECTIVE-C
Apple's release of Swift in June 2014 came as a surprise to many iOS and OS X programmers. For years, there had been speculation that Apple would release a successor to Objective-C. In 2008, development on MacRuby, an implementation of Ruby that offered near-seamless bridging between Ruby and Objective-C, ramped up. Many programmers believed that Apple would eventually bless Ruby as the ...