Swift by Example
eBook - ePub

Swift by Example

Giordano Scalzo

Partager le livre
  1. 284 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Swift by Example

Giordano Scalzo

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Swift by Example est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Swift by Example par Giordano Scalzo en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming Games. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2015
ISBN
9781785284700
Édition
1

Swift by Example


Table of Contents

Swift by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Welcome to the World of Swift
The first look at Swift
Let's go to the playground
The building blocks – variables and constants
Collect variables in containers
Controlling the flow
Transforming the values using functions
Structs – custom compounds type
Classes – common behavior objects
Loose coupling with protocols
Check the existence of an optionals value
Enumerations on steroids
A Guess the Number app in Swift
The app is

Building a skeleton app
Adding the graphic components
Connecting the dots
Adding the code
Summary
2. A Memory Game in Swift
The app is

Building the skeleton of the app
The menu screen
Implementing the basic menu screen
Creating a nice menu screen
The game screen
The structure
Adding the collectionView class
Sizing the components
Connecting the datasource and the delegate
Implementing a deck of cards
What we are expecting
The Card entity
Crafting the deck
Shuffling the deck
Finishing the deck
Put the cards on the table
Adding the assets
The CardCell structure
Handling touches
Finishing the game
Implementing the game logic
We got a pair
We played a wrong turn
Et voilĂ ! The game is completed
Summary
3. A TodoList App in Swift
The app is

Building a skeleton app
Implementing an empty app
Adding third-party libraries with CocoaPods
Implementing the Todos ViewController
Building the Todos screen
Adding the entities
Implementing the datastore
Connecting the datastore and the ViewController
Configuring tableView
Implementing TodoViewCell
Swipe that cell!
Adding a Todo task
The add a Todo ViewController
Updating the datastore
Adding a list
Implementing ListViewCell
Building ListViewController
Updating the datastore
Where do we go from here?
Summary
4. A Pretty Weather App
The app is

Building the skeleton
Creating the project
Adding the assets
Implementing the UI
The UI in blocks
Completing the UI
CurrentWeatherView
WeatherHourlyForecastView
WeatherDaysForecastView
Blurring the background
Downloading the background image
Searching in Flickr
Geolocalising the app
Using CoreLocation
Retrieving the actual forecast
Getting the forecast from OpenWeatherMap
Rendering CurrentWeatherView
Rendering WeatherHourlyForecastView
Rendering WeatherDaysForecastView
Connecting to the server
Where do we go from here?
Summary
5. Flappy Swift
The app is

Building the skeleton of the app
Creating the project
Implementing the menu
A stage for a bird
SpriteKit in a nutshell
Explaining the code
Simulating a three-dimensional world using parallax
How to implement the scrolling
A flying bird
Adding the Bird node
Making the bird flap
Pipes!
Implementing the pipes node
Making the components interact
Setting up the collision detection engine
Completing the game
Colliding with the pipes
Adding the score
Adding a restarting popup
Summary
6. Polishing Flappy Swift
Adding juiciness
Let there be sounds!
Playing the soundtrack
Shaking the screen!
Integrating with Game Center
What Game Center provides
Setting up Game Center
Creating an app record on iTunes Connect
Enabling Game Center
Creating fake user accounts to test Game Center
Authenticating a player
Summary
7. Cube Runner
The app is

Introduction to SceneKit
What is SceneKit?
Building an empty scene
Adding a green torus
Let there be light!
Let's make it move!
Implementing Cube Runner
The game skeleton
Implementing the menu
Flying in a 3D world
Setting up the scene
Adding the fighter
Texturing the world
Make it move
Adding the cubes
Adding more obstacles
Adding a few touches
The score
Let's add the music
Summary
8. Completing Cube Runner
Making it a real game
Detecting collisions
Game Over!
Adding the juice
Game Center
Summary
Index

Swift by Example

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2015
Production reference: 1120615
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-470-0
www.packtpub.com

Credits

Author
Giordano Scalzo
Reviewers
Eugene Mozharovsky
Alexey Smirnov
Sumit Tiwari
Commissioning Editor
Nadeem N. Bagban
Acquisition Editors
Richard Brookes-Bland
Nikhil Karkal
Content Development Editor
Neeshma Ramakrishnan
Technical Editor
Faisal Siddiqui
Copy Editor
Vikrant Phadke
Project Coordinator
Shweta Birwatkar
Proofreader
Safis Editing
Indexer
Tejal Soni
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa

About the Author

Giordano Scalzo is a developer with 20 years of programming experience since the days of the ZX Spectrum. He has worked using C++, Java, .NET, Ruby, Python, and a ton of other languages whose names he has forgotten.
After several years of backend development, over the past 5 years, he has developed extensively for iOS, releasing more than 20 apps—apps that he wrote for clients, enterprises, or himself.
Currently, Giordano is a contractor in London, where he delivers code for iOS through his company, Effective Code (http://effectivecode.co.uk), aiming at quality and reliability. In his spare time, when he is not crafting retro game clones for iOS, he writes his thou...

Table des matiĂšres