Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Swift Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
Swift Essentials

Swift Essentials

By : Alex Blewitt, Bandlem Limited
4.8 (4)
close
close
Swift Essentials

Swift Essentials

4.8 (4)
By: Alex Blewitt, Bandlem Limited

Overview of this book

Whether you are a seasoned Objective-C developer or new to the Xcode platform, Swift Essentials will provide you with all you need to know to get started with the language. Prior experience with iOS development is not necessary, but will be helpful to get the most out of the book.
Table of Contents (10 chapters)
close
close
9
Index

Swift classes, protocols, and enums

Almost all Swift applications will be object oriented. Chapter 1, Exploring Swift, and Chapter 2, Playing with Swift, both demonstrated functional and procedural Swift code. Classes such as Process from the CoreFoundation framework, and UIColor and UIImage from the UIKit framework were used to demonstrate how classes can be used in applications. This section describes how to create classes, protocols, and enums in Swift.

Classes in Swift

A class is created in Swift using the class keyword and braces are used to enclose the class body. The body can contain variables called properties as well as functions called methods, which are collectively referred to as members. Instance members are unique to each instance, while class members are shared between all instances of that class.

Classes are typically defined in a file named for the class; so a GitHubRepository class can be defined in the GitHubRepository.swift file. A new Swift file can be created by navigating...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY