Search icon CANCEL
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
Beginning Swift

You're reading from   Beginning Swift Master the fundamentals of programming in Swift 4

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781789534313
Length 202 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Rob Kerr Rob Kerr
Author Profile Icon Rob Kerr
Rob Kerr
Kåre Morstøl Kåre Morstøl
Author Profile Icon Kåre Morstøl
Kåre Morstøl
Arrow right icon
View More author details
Toc

Chapter 4. Collections

In the previous lesson, we looked into building Swift functions, error handling, and developing fully-featured Swift programs. We also briefly looked at a few OOP features.

In this lesson, we will work extensively with Swift's collections, such as arrays, sets, and dictionaries.

The Swift Standard Library ( https://developer.apple.com/documentation/swift) is automatically imported into all Swift code, and contains basic types such as Int, Double, Bool, Optional, and more. It is primarily organized around protocols, because Swift is a Protocol-Oriented language ( https://developer.apple.com/videos/play/wwdc2015/408/).

The root protocol for collections, which they all inherit from, is Sequence. All a type needs to conform to it is the ability to provide one value at a time, until it is empty, at which point it will output nil. This simple requirement provides a long list of methods ( https://developer.apple.com/documentation...

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 €18.99/month. Cancel anytime