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

Measurements and units


With Swift 3's release, the Foundation team is releasing a new API to make handling measurements easier for developers. By allowing developers to create measurements from common built-in units (or create custom ones), convert between units and format them for display. We will cover each of the main areas of the Measurement API to get you ready to use them in your projects.

Measurement

A measurement is composed of a unit and a value. A unit is a class that contains a single property to hold a symbol. We will come back to units in a moment. For now, let's focus on what you can do with a measurement.

public struct Measurement<UnitType : Unit> : ReferenceConvertible, Comparable, Equatable { 
 
    public typealias ReferenceType = NSMeasurement 
 
    /// The unit component of the `Measurement`. 
    public let unit: UnitType 
 
    /// The value component of the `Measurement`. 
    public var value: Double 
 
    //...
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}