Beginning iPhone Development with Swift 4: Exploring the iOS SDK 4th Edition Molly K. Maskrey 2024 Scribd Download
Beginning iPhone Development with Swift 4: Exploring the iOS SDK 4th Edition Molly K. Maskrey 2024 Scribd Download
com
https://ebookmeta.com/product/beginning-iphone-development-
with-swift-4-exploring-the-ios-sdk-4th-edition-molly-k-
maskrey/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/beginning-iphone-development-with-
swift-5-5th-edition-exploring-the-ios-sdk-wallace-wang/
ebookmeta.com
https://ebookmeta.com/product/beginning-iphone-development-with-
swiftui-exploring-the-ios-sdk-6th-edition-wally-wang/
ebookmeta.com
https://ebookmeta.com/product/beginning-iphone-development-with-
swiftui-exploring-the-ios-sdk-7th-edition-wallace-wang/
ebookmeta.com
https://ebookmeta.com/product/advanced-r-solutions-1st-edition-malte-
grosser-2/
ebookmeta.com
Alternative Pathways to Sustainable Development Lessons
from Latin America 9 International Development Policy
Gilles Carbonnier
https://ebookmeta.com/product/alternative-pathways-to-sustainable-
development-lessons-from-latin-america-9-international-development-
policy-gilles-carbonnier/
ebookmeta.com
https://ebookmeta.com/product/foundations-of-comparative-politics-
democracies-of-the-modern-world-4th-edition-kenneth-newton/
ebookmeta.com
https://ebookmeta.com/product/youngblood-1st-edition-sasha-laurens/
ebookmeta.com
https://ebookmeta.com/product/jfk-vs-allen-dulles-1st-edition-greg-
poulgrain/
ebookmeta.com
There Was a Young Rabbi A Hanukkah Tale Suzanne Wolfe
https://ebookmeta.com/product/there-was-a-young-rabbi-a-hanukkah-tale-
suzanne-wolfe/
ebookmeta.com
Beginning iPhone
Development
with Swift 4
Exploring the iOS SDK
—
Fourth Edition
—
Molly K. Maskrey
www.allitebooks.com
Beginning iPhone
Development with
Swift 4
Exploring the iOS SDK
Fourth Edition
Molly K. Maskrey
www.allitebooks.com
Beginning iPhone Development with Swift 4: Exploring the iOS SDK
Molly K. Maskrey
Parker, Colorado, USA
ISBN-13 (pbk): 978-1-4842-3071-8 ISBN-13 (electronic): 978-1-4842-3072-5
https://doi.org/10.1007/978-1-4842-3072-5
Library of Congress Control Number: 2017957132
Copyright © 2017 by Molly K. Maskrey
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material
is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting,
reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter
developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly
analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for
exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under
the provisions of the Copyright Law of the Publisher's location, in its current version, and permission for use must
always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright
Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material
contained herein.
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Aaron Black
Development Editor: James Markham
Technical Reviewer: Bruce Wade
Coordinating Editor: Jessica Vakili
Copy Editor: Kim Wimpsett
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springer.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available to
readers at www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/.
Printed on acid-free paper
www.allitebooks.com
Another year, another revision of this book, as well as one of my own personal tribe.
Still around after more than two years of ups and downs, KP stuck beside me during my
most difficult times. No matter what I did, her sanity and silliness kept me going. She was,
for a long while, my muse…my inspiration to write and to keep it as fun as possible…never
taking myself too seriously. Now, as our paths slightly diverge, the qualities she’s left permeate
my days and make me a better self.
Mellie has been my rock. We’ve been in and out of being friends, and I hope she knows
I consider her the closest friend I’ve ever had. I probably wouldn’t be doing this if it weren’t
for the love she’s shown me.
Tonya came into my life recently and has been such a godsend to help me become more
confident in all I say and do, and I can’t thank her enough.
She probably has no clue she’s in here, but Lauren kept me going for the past year.
When I would’ve preferred to lay in the dark and sleep and zone out, without any
aggressiveness Lauren would give me something in her words to keep to going…to
not give up. She—I won’t say forced, but she was very persuasive—got me into a
program that is, this very day, putting me onto a better path for myself and my future and
the future of anyone alongside me for my journey.
Finally, to Jennifer…our lives have radically changed over the past year. But, as partners
in business and advocates for each other’s happy life, our relationship bond, while admittedly
very tumultuous, has solidified into something we both see as pretty damn good.
In my personal struggles over the preceding year, these friends kept me from falling into
an abyss so deep I might never have returned. Writing can be a lonely thing, and having
a support system such as these beautiful, wonderful women are the only reason this endeavor
was a success. A special friend told me last year that some friends are only in your life for
a season. I pray that these women are friends for a lifetime.
—MM, August 2017
www.allitebooks.com
Contents at a Glance
■
■Chapter 1: Getting to Know the iOS Landscape����������������������������������������������������� 1
■
■Chapter 2: Writing Your First App������������������������������������������������������������������������ 13
■
■Chapter 3: Basic User Interactions���������������������������������������������������������������������� 51
■
■Chapter 4: Adding Intermediate-Level User Interactions������������������������������������ 87
■
■Chapter 5: Working with Device Rotations�������������������������������������������������������� 131
■
■Chapter 6: Creating a Multiview Application����������������������������������������������������� 179
■
■Chapter 7: Using Tab Bars and Pickers������������������������������������������������������������� 209
■
■Chapter 8: Introducing Table Views������������������������������������������������������������������� 255
■
■Chapter 9: Adding Navigation Controllers to Table Views��������������������������������� 309
■
■Chapter 10: Collection Views����������������������������������������������������������������������������� 343
■
■Chapter 11: Split Views and Popovers for iPad Apps���������������������������������������� 357
■
■Chapter 12: App Customization with Settings and Defaults������������������������������ 383
■
■Chapter 13: Persistence: Saving Data Between App Launches������������������������� 419
■
■Chapter 14: Graphics and Drawing�������������������������������������������������������������������� 465
■
■Appendix A: An Introduction to Swift���������������������������������������������������������������� 491
Index��������������������������������������������������������������������������������������������������������������������� 547
www.allitebooks.com
Contents
■
■Chapter 1: Getting to Know the iOS Landscape����������������������������������������������������� 1
About the Book����������������������������������������������������������������������������������������������������������������� 2
Things You’ll Need������������������������������������������������������������������������������������������������������������ 2
Your Options as a Developer������������������������������������������������������������������������������������������������������������������� 4
Things You Should Know������������������������������������������������������������������������������������������������������������������������ 6
Some Unique Aspects About Working in iOS������������������������������������������������������������������������������������������ 6
vii
www.allitebooks.com
■ Contents
viii
www.allitebooks.com
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 130
■
■Chapter 5: Working with Device Rotations�������������������������������������������������������� 131
Understanding the Mechanics of Rotation������������������������������������������������������������������� 132
Understanding Points, Pixels, and the Retina Display������������������������������������������������������������������������ 132
Handling Rotation������������������������������������������������������������������������������������������������������������������������������� 133
ix
www.allitebooks.com
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 178
■
■Chapter 6: Creating a Multiview Application����������������������������������������������������� 179
Looking at Common Types of Multiview Apps�������������������������������������������������������������� 179
Looking at the Architecture of a Multiview Application������������������������������������������������ 185
Understanding the Root Controller����������������������������������������������������������������������������������������������������� 188
Content View Anatomy������������������������������������������������������������������������������������������������������������������������ 188
Summary���������������������������������������������������������������������������������������������������������������������� 207
■
■Chapter 7: Using Tab Bars and Pickers������������������������������������������������������������� 209
The Pickers Application������������������������������������������������������������������������������������������������ 210
Delegates and Data Sources���������������������������������������������������������������������������������������� 216
www.allitebooks.com
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 253
■
■Chapter 8: Introducing Table Views������������������������������������������������������������������� 255
Understanding Table View Basics��������������������������������������������������������������������������������� 256
Using Table Views and Table View Cells��������������������������������������������������������������������������������������������� 256
Understanding Grouped and Plain Tables������������������������������������������������������������������������������������������� 257
xi
www.allitebooks.com
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 307
■
■Chapter 9: Adding Navigation Controllers to Table Views��������������������������������� 309
Understanding Navigation Controller Basics���������������������������������������������������������������� 309
Using Stacks��������������������������������������������������������������������������������������������������������������������������������������� 310
Using a Stack of Controllers��������������������������������������������������������������������������������������������������������������� 311
xii
■ Contents
Adapting the Font List View Controller for Multiple Segues��������������������������������������������������������������� 337
Creating My Favorite Fonts����������������������������������������������������������������������������������������������������������������� 337
Adding Features��������������������������������������������������������������������������������������������������������������������������������� 338
Implementing Swipe-to-Delete���������������������������������������������������������������������������������������������������������� 338
Implementing Drag-to-Reorder���������������������������������������������������������������������������������������������������������� 340
Summary���������������������������������������������������������������������������������������������������������������������� 342
■
■Chapter 10: Collection Views����������������������������������������������������������������������������� 343
Creating the DialogViewer Project�������������������������������������������������������������������������������� 343
Defining Custom Cells������������������������������������������������������������������������������������������������������������������������ 345
Configuring the View Controller���������������������������������������������������������������������������������������������������������� 348
Providing Content Cells���������������������������������������������������������������������������������������������������������������������� 349
Creating the Layout Flow�������������������������������������������������������������������������������������������������������������������� 351
Implementing the Header Views��������������������������������������������������������������������������������������������������������� 353
Summary���������������������������������������������������������������������������������������������������������������������� 355
■
■Chapter 11: Split Views and Popovers for iPad Apps���������������������������������������� 357
Building Master-Detail Applications with UISplitViewController����������������������������������� 359
Understanding How the Storyboard Defines the Structure���������������������������������������������������������������� 361
Understanding How Code Defines the Functionality�������������������������������������������������������������������������� 363
Understanding How the Master-Detail Template Application Works��������������������������������������������������� 367
Adding the President Data������������������������������������������������������������������������������������������������������������������ 369
Creating Your Own Popover���������������������������������������������������������������������������������������������������������������� 375
Summary���������������������������������������������������������������������������������������������������������������������� 381
■
■Chapter 12: App Customization with Settings and Defaults������������������������������ 383
Exploring the Settings Bundle�������������������������������������������������������������������������������������� 383
Creating the Bridge Control Application����������������������������������������������������������������������� 385
Creating the Bridge Control Project���������������������������������������������������������������������������������������������������� 390
Working with the Settings Bundle������������������������������������������������������������������������������������������������������ 391
Reading Settings in Your Application�������������������������������������������������������������������������������������������������� 408
Changing Defaults from Your Application������������������������������������������������������������������������������������������� 412
xiii
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 418
■
■Chapter 13: Persistence: Saving Data Between App Launches������������������������� 419
Your Application’s Sandbox������������������������������������������������������������������������������������������ 419
Getting the Documents and Library Directories���������������������������������������������������������������������������������� 423
Getting the tmp Directory������������������������������������������������������������������������������������������������������������������� 424
Summary���������������������������������������������������������������������������������������������������������������������� 463
xiv
■ Contents
■
■Chapter 14: Graphics and Drawing�������������������������������������������������������������������� 465
Quartz 2D��������������������������������������������������������������������������������������������������������������������� 466
The Quartz 2D Approach to Drawing���������������������������������������������������������������������������� 466
Quartz 2D’s Graphics Contexts����������������������������������������������������������������������������������������������������������� 466
The Coordinate System���������������������������������������������������������������������������������������������������������������������� 467
Specifying Colors�������������������������������������������������������������������������������������������������������������������������������� 470
Drawing Images in Context����������������������������������������������������������������������������������������������������������������� 471
Drawing Shapes: Polygons, Lines, and Curves����������������������������������������������������������������������������������� 472
Quartz 2D Tool Sampler: Patterns, Gradients, and Dash Patterns������������������������������������������������������� 472
Summary���������������������������������������������������������������������������������������������������������������������� 490
■
■Appendix A: An Introduction to Swift���������������������������������������������������������������� 491
Swift Basics����������������������������������������������������������������������������������������������������������������� 491
Playgrounds, Comments, Variables, and Constants���������������������������������������������������������������������������� 493
Predefined Types, Operators, and Control Statements����������������������������������������������������������������������� 496
Arrays, Ranges, and Dictionaries�������������������������������������������������������������������������������������������������������� 507
Optionals��������������������������������������������������������������������������������������������������������������������������������������������� 512
Control Statements����������������������������������������������������������������������������������������������������������������������������� 517
Functions and Closures���������������������������������������������������������������������������������������������������������������������� 522
Error Handling������������������������������������������������������������������������������������������������������������������������������������� 527
Classes and Structures����������������������������������������������������������������������������������������������������������������������� 533
Structures������������������������������������������������������������������������������������������������������������������������������������������� 533
Classes����������������������������������������������������������������������������������������������������������������������������������������������� 535
Properties������������������������������������������������������������������������������������������������������������������������������������������� 536
Methods���������������������������������������������������������������������������������������������������������������������������������������������� 539
Optional Chaining������������������������������������������������������������������������������������������������������������������������������� 540
xv
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 546
Index��������������������������������������������������������������������������������������������������������������������� 547
xvi
Other documents randomly have
different content
KARAVAANI
DE PROFUNDIS
NÄKY KADULTA
Se etäisille retkilleen
läks siivin kuulumattomin,
niin häikäisevän valkoisin —
ja palas pesälleen.
Ja hiljaisesti valittain
lens valkosiipi povestain,
se lensi eikä levännyt —
ja poissa on se nyt.
HÄMÄHÄKKI
— Mut sitten, aurinko, kun ylle pääni, tään rotkon ylle sytyt,
silmäs näkee mun, niin huutaa lahonneiden luiden ääni: Täss'
olen — poikas sun!
ERÄS IN MEMORIAM