Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
iOS 10 Programming for Beginners

You're reading from   iOS 10 Programming for Beginners Explore the latest iOS 10 and Swift 3 features

Arrow left icon
Product type Paperback
Published in Dec 2016
Publisher Packt
ISBN-13 9781786464507
Length 678 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Craig Clayton Craig Clayton
Author Profile Icon Craig Clayton
Craig Clayton
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Getting Familiar with Xcode FREE CHAPTER 2. Building a Foundation with Swift 3. Digging Deeper 4. Digging into Collections 5. Starting the UI Setup 6. Setting Up UI 7. Getting Started with the Grid 8. Getting Started with the List 9. Working More with Lists 10. Where Are We? 11. Where's My Data? 12. Foodie Reviews 13. Saving Reviews 14. Universal 15. iMessages 16. Notifications 17. Just a Peek 18. Beta and Store Submission Index

Ranges

Ranges are generic data types that represent a sequence of numbers. Let's look at the following image to understand:

Ranges

Closed Range

Notice that, in the preceding image, we have numbers ranging from 10 to 20. Rather than having to write each value, we can use Ranges to represent all of these numbers in shorthand form. In order to do this, let's remove all of the numbers in the image except 10 and 20:

Closed Range

Now that we have removed those numbers, we need a way to tell Swift that we want to include all of the numbers that we just deleted. This is where the range operator () comes into play. Therefore, in Playgrounds, let's create a constant called range and set it equal to 10...20:

let range = 10...20
Closed Range

The range that we just entered says that we want the numbers between 10 and 20 as well as both 10 and 20 themselves. This type of Range is known as a closed Range. We also have what is called a half closed Range.

Half closed Range

Let's make another constant that is known...

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 $19.99/month. Cancel anytime