Reader small image

You're reading from  Swift 3 New Features

Product typeBook
Published inOct 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781786469632
Edition1st Edition
Languages
Right arrow
Author (1)
Keith Elliott
Keith Elliott
author image
Keith Elliott

Keith Elliott is a multitalented professional with unique business and technology experience spanning telecommunications, real estate investment banking, and capital markets. His work is driven simply by problems that need solutions, whether the problem is as simple as his wifes request for a custom to-do list or as complex as interest rate derivatives and foreign exchange hedging. He graduated with an MBA from Columbia Business School with an emphasis in entrepreneurship and an undergraduate degree from Georgia Institute of Technology with a bachelor's in computer engineering. Keith's own company, GittieLabs LLC, works with startups to provide technology solutions. His vision is to equip students with the real-life experience necessary to succeed in startup and corporate life. You can find his blog on the GittieLabs LLC website, www.gittie.com. On nights and weekends, Keith can be found spending time with his family, riding motorcycles with his lovely wife, watching football, and rewatching countless hours of WWDC videos.
Read more about Keith Elliott

Right arrow

Nested enumerations


The Foundation framework takes advantage of Swift 3's new nested enumeration feature. This feature allows the migrator to import related Objective-C enumerations into Swift under a common type. For example, the NSDateFormatterStyle and NSDateFormatterBehavior enumerations are imported as nested enumerations to the DateFormatter class in Swift. Let's see how we get to a nested enumeration in Swift 3, starting with an Objective-C enumeration.

In Objective-C:

typedef NS_ENUM(NSUInteger, NSDateFormatterStyle), 
{ 
   NSDateFormatterNoStyle     = kCFDateFormatterNoStyle, 
   NSDateFormatterShortStyle  = kCFDateFormatterShortStyle, 
   NSDateFormatterMediumStyle = kCFDateFormatterMediumStyle, 
   NSDateFormatterLongStyle   = kCFDateFormatterLongStyle, 
   NSDateFormatterFullStyle   = kCFDateFormatterFullStyle 
}; 
 
typedef NS_ENUM(NSUInteger, NSDateFormatterBehavior){ 
   NSDateFormatterBehaviorDefault = 0, 
   NSDateFormatterBehavior10_0...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Swift 3 New Features
Published in: Oct 2016Publisher: PacktISBN-13: 9781786469632

Author (1)

author image
Keith Elliott

Keith Elliott is a multitalented professional with unique business and technology experience spanning telecommunications, real estate investment banking, and capital markets. His work is driven simply by problems that need solutions, whether the problem is as simple as his wifes request for a custom to-do list or as complex as interest rate derivatives and foreign exchange hedging. He graduated with an MBA from Columbia Business School with an emphasis in entrepreneurship and an undergraduate degree from Georgia Institute of Technology with a bachelor's in computer engineering. Keith's own company, GittieLabs LLC, works with startups to provide technology solutions. His vision is to equip students with the real-life experience necessary to succeed in startup and corporate life. You can find his blog on the GittieLabs LLC website, www.gittie.com. On nights and weekends, Keith can be found spending time with his family, riding motorcycles with his lovely wife, watching football, and rewatching countless hours of WWDC videos.
Read more about Keith Elliott