Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Swift 3 New Features

You're reading from  Swift 3 New Features

Product type Book
Published in Oct 2016
Publisher Packt
ISBN-13 9781786469632
Pages 142 pages
Edition 1st Edition
Languages
Author (1):
Keith Elliott Keith Elliott
Profile icon Keith Elliott

Table of Contents (16) Chapters

Swift 3 New Features
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. What Were They Thinking? 2. Discovering New Territories – Linux at Last! 3. Migrating to Swift 3 to Be More Swifty 4. Changes to Swifts Core Will Have You Asking for More 5. Function and Operator Changes – New Ways to Get Things Done 6. Extra, Extra Collection and Closure Changes That Rock! 7. Hold onto Your Chair; Advanced Type Changes Are Here! 8. Oh Goodness! Look Whats New in the Foundation Framework 9. Improving Your Code with Xcode Server and LLDB Debugging 10. Exploring Swift on the Server

Importing code from Objective-C and C APIs to Swift 3


If you maintain Objective-C or C libraries and want to expose cleaner syntax for Swift, this section is for you! We now have the ability to provide more control over how constants, global functions, and generics are imported from Objective-C and C into Swift.

Importing Objective-C constants as Swift types [SE-0033]

Constants with global scope, defined in header files, are imported with the same global scope in Swift. In many cases, it would be more helpful to have related constants grouped together. In Swift 3, you can now annotate your type declarations with NS_STRING_ENUM or NS_EXTENSIBLE_STRING_ENUM to have those declarations imported as members of a common type.

Importing as Struct

If you want your constants to be imported as members of a struct, then add NS_EXTENSIBLE_STRING_ENUM to the end of your constant type declaration. For more consistent importing into Swift, name your constants using the same type as a prefix. In our example...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}