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

Strongly typed string enumerations


The Foundation framework has a lot of string-based constants. For example, UIKit uses NSNotifications to publishing notifications for an iOS app's lifecycle.

NSString *const UIApplicationDidEnterBackgroundNotification        
NSString *const UIApplicationWillEnterForegroundNotification      NSString *const UIApplicationDidFinishLaunchingNotification; 

New for Foundation, Objective-C now has the ability to use strongly typed string enumerations. This new feature allowed the Foundation team to update the enumerations in Objective-C. Our notifications listed earlier can now use the NSNotificationName type and convert our preceding constants to:

In Objective-C:

typedef NSString *NSNotificationName NS_EXTENSIBLE_STRING_ENUM; 
NSNotificationName const UIApplicationDidEnterBackgroundNotification        
NSNotificationName const UIApplicationWillEnterForegroundNotification      NSNotificationName const UIApplicationDidFinishLaunchingNotification...
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