100% found this document useful (1 vote)
6 views

iOS 10 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 3rd Edition Matt Neuburg instant download

The document is an overview of the book 'iOS 10 Programming Fundamentals with Swift' by Matt Neuburg, detailing its content and structure. It includes links to various editions of the book and other related titles by the same author. The book covers Swift programming language fundamentals, Xcode, and Cocoa basics, aimed at helping readers understand iOS development.

Uploaded by

wrslqdvn7343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
6 views

iOS 10 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 3rd Edition Matt Neuburg instant download

The document is an overview of the book 'iOS 10 Programming Fundamentals with Swift' by Matt Neuburg, detailing its content and structure. It includes links to various editions of the book and other related titles by the same author. The book covers Swift programming language fundamentals, Xcode, and Cocoa basics, aimed at helping readers understand iOS development.

Uploaded by

wrslqdvn7343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

iOS 10 Programming Fundamentals with Swift Swift

Xcode and Cocoa Basics 3rd Edition Matt Neuburg


download

https://textbookfull.com/product/ios-10-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-3rd-edition-matt-neuburg/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

iOS 12 Programming Fundamentals with Swift Swift Xcode


and Cocoa Basics 5th Edition Matt Neuburg

https://textbookfull.com/product/ios-12-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-5th-edition-matt-neuburg/

iOS 11 Programming Fundamentals with Swift Swift Xcode


and Cocoa Basics 4th Edition Matt Neuburg

https://textbookfull.com/product/ios-11-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-4th-edition-matt-neuburg/

iOS 13 Programming Fundamentals with Swift Swift Xcode


and Cocoa Basics 1st Edition Matt Neuburg

https://textbookfull.com/product/ios-13-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-1st-edition-matt-neuburg/

iOS 12 Programming Fundamentals with Swift Swift Xcode


and Cocoa Basics 5th Edition Matt Neuburg

https://textbookfull.com/product/ios-12-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-5th-edition-matt-
neuburg-2/
iOS 12 Programming Fundamentals with Swift Swift Xcode
and Cocoa Basics 5th Edition Matt Neuburg

https://textbookfull.com/product/ios-12-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-5th-edition-matt-
neuburg-3/

iOS 14 Programming Fundamentals with Swift Covers iOS


14 Xcode 12 and Swift 5 3 7th Edition Matt Neuburg

https://textbookfull.com/product/ios-14-programming-fundamentals-
with-swift-covers-ios-14-xcode-12-and-swift-5-3-7th-edition-matt-
neuburg/

Programming iOS 14 11th Edition Matt Neuburg

https://textbookfull.com/product/programming-ios-14-11th-edition-
matt-neuburg/

Learn iOS 11 Programming with Swift 4 Craig Clayton

https://textbookfull.com/product/learn-ios-11-programming-with-
swift-4-craig-clayton/

Programming iOS 10 Dive Deep into Views View


Controllers and Frameworks Seventh Edition Matt Neuburg

https://textbookfull.com/product/programming-ios-10-dive-deep-
into-views-view-controllers-and-frameworks-seventh-edition-matt-
neuburg/
Xc
Co e 8
od
ve , a
rs nd
i O Sw
S 1 if
0, t 3
iOS 10
Programming
Fundamentals
with Swift
SWIFT, XCODE, AND COCOA BASICS

Matt Neuburg
THIRD EDITION

iOS 10 Programming
Fundamentals with Swift
Swift, Xcode, and Cocoa Basics

Matt Neuburg

Boston
iOS 10 Programming Fundamentals with Swift, Third Edition
by Matt Neuburg
Copyright © 2017 Matt Neuburg. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or [email protected].

Editor: Rachel Roumeliotis Cover Designer: Karen Montgomery


Production Editor: Kristen Brown Interior Designer: David Futato
Proofreader: O’Reilly Production Services Illustrator: Matt Neuburg
Indexer: Matt Neuburg

April 2015: First Edition


October 2015: Second Edition
October 2016: Third Edition

Revision History for the Third Edition


2016-09-23: First release

See http://oreilly.com/catalog/errata.csp?isbn=9781491970072 for release details.

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. iOS 10 Programming Fundamentals
with Swift, the image of a harp seal, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.

ISBN: 978-1-491-97007-2
[LSI]
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

Part I. Language
1. The Architecture of Swift. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Ground of Being 3
Everything Is an Object? 5
Three Flavors of Object Type 6
Variables 6
Functions 8
The Structure of a Swift File 9
Scope and Lifetime 11
Object Members 12
Namespaces 13
Modules 14
Instances 15
Why Instances? 17
self 19
Privacy 20
Design 22
Object Types and APIs 23
Instance Creation, Scope, and Lifetime 25
Summary and Conclusion 26

2. Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Function Parameters and Return Value 27
Void Return Type and Parameters 31
Function Signature 32

iii
External Parameter Names 32
Overloading 34
Default Parameter Values 35
Variadic Parameters 36
Ignored Parameters 36
Modifiable Parameters 37
Function In Function 41
Recursion 43
Function As Value 43
Anonymous Functions 46
Define-and-Call 52
Closures 53
How Closures Improve Code 54
Function Returning Function 56
Closure Setting a Captured Variable 58
Closure Preserving Its Captured Environment 59
Escaping Closures 60
Curried Functions 61
Function References and Selectors 62
Function Reference Scope 65
Selectors 66

3. Variables and Simple Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69


Variable Scope and Lifetime 69
Variable Declaration 71
Computed Initializer 74
Computed Variables 75
Setter Observers 78
Lazy Initialization 80
Built-In Simple Types 82
Bool 82
Numbers 84
String 90
Character 95
Range 98
Tuple 100
Optional 103

4. Object Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117


Object Type Declarations and Features 117
Initializers 119
Properties 125

iv | Table of Contents
Methods 128
Subscripts 130
Nested Object Types 132
Instance References 133
Enums 135
Raw Values 137
Associated Values 138
Enum Initializers 139
Enum Properties 140
Enum Methods 141
Why Enums? 142
Structs 143
Struct Initializers, Properties, and Methods 144
Struct As Namespace 145
Classes 146
Value Types and Reference Types 146
Subclass and Superclass 151
Class Initializers 156
Class Deinitializer 164
Class Properties and Methods 164
Polymorphism 166
Casting 169
Type Reference 174
Protocols 179
Why Protocols? 181
Protocol Type Testing and Casting 183
Declaring a Protocol 183
Optional Protocol Members 185
Class Protocol 186
Implicitly Required Initializers 187
Literal Convertibles 189
Generics 190
Generic Declarations 192
Type Constraints 194
Explicit Specialization 196
Associated Type Chains 197
Additional Constraints 200
Extensions 203
Extending Object Types 203
Extending Protocols 206
Extending Generics 209
Umbrella Types 210

Table of Contents | v
Any 211
AnyObject 212
AnyClass 215
Collection Types 216
Array 216
Dictionary 230
Set 235

5. Flow Control and More. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241


Flow Control 241
Branching 242
Loops 254
Jumping 259
Operators 274
Privacy 277
Private and Fileprivate 278
Public and Open 280
Privacy Rules 280
Introspection 281
Memory Management 282
Weak References 284
Unowned References 285
Weak and Unowned References in Anonymous Functions 287
Memory Management of Protocol-Typed References 290

Part II. IDE


6. Anatomy of an Xcode Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
New Project 294
The Project Window 296
The Navigator Pane 297
The Utilities Pane 303
The Editor 304
The Project File and Its Dependents 306
The Target 309
Build Phases 310
Build Settings 312
Configurations 313
Schemes and Destinations 314
From Project to Running App 316
Build Settings 319

vi | Table of Contents
Property List Settings 319
Nib Files 320
Additional Resources 321
Code Files and the App Launch Process 324
Frameworks and SDKs 329
Renaming Parts of a Project 331

7. Nib Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333


The Nib Editor Interface 335
Document Outline 336
Canvas 339
Inspectors and Libraries 341
Nib Loading 342
When Nibs Are Loaded 343
Manual Nib Loading 344
Connections 346
Outlets 346
The Nib Owner 348
Automatically Configured Nibs 351
Misconfigured Outlets 352
Deleting an Outlet 353
More Ways to Create Outlets 354
Outlet Collections 357
Action Connections 357
More Ways to Create Actions 360
Misconfigured Actions 361
Connections Between Nibs — Not! 361
Additional Configuration of Nib-Based Instances 362

8. Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
The Documentation Window 367
Class Documentation Pages 369
Quick Help 372
Symbols 374
Header Files 375
Sample Code 376
Internet Resources 376

9. Life Cycle of a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379


Device Architecture and Conditional Code 379
Backward Compatibility 380
Device Type 381

Table of Contents | vii


Version Control 383
Editing and Navigating Your Code 385
Autocompletion 386
Snippets 388
Fix-it and Live Syntax Checking 389
Navigation 390
Finding 391
Running in the Simulator 393
Debugging 394
Caveman Debugging 394
The Xcode Debugger 396
Testing 403
Clean 409
Running on a Device 410
Obtaining a Developer Program Membership 410
Signing an App 411
Automatic Development Signing 412
Obtaining a Development Certificate Manually 415
Obtaining a Development Provisioning Profile Manually 416
Running the App 418
Managing Certificates, Profiles, and Devices 418
Profiling 419
Gauges 420
Memory Debugging 421
Instruments 422
Localization 425
Localizing the Info.plist 426
Localizing a Nib File 427
Localizing Code Strings 429
Localizing With XML Files 431
Distribution 433
Making an Archive 433
Obtaining a Distribution Certificate Manually 434
Obtaining a Distribution Profile Manually 435
Ad Hoc Distribution 436
Final App Preparations 437
Icons in the App 437
Other Icons 439
Launch Images 439
Screenshots and Video Previews 440
Property List Settings 442

viii | Table of Contents


Submission to the App Store 443

Part III. Cocoa


10. Cocoa Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Subclassing 447
Categories and Extensions 450
How Swift Uses Extensions 451
How You Use Extensions 451
How Cocoa Uses Categories 452
Protocols 453
Informal Protocols 455
Optional Methods 456
Some Foundation Classes 458
Useful Structs and Constants 459
NSString and Friends 461
NSDate and Friends 464
NSNumber 465
NSValue 467
NSData 468
NSMeasurement and Friends 469
Equality and Comparison 469
NSArray and NSMutableArray 471
NSDictionary and NSMutableDictionary 473
NSSet and Friends 473
NSIndexSet 474
NSNull 475
Immutable and Mutable 475
Property Lists 477
Accessors, Properties, and Key–Value Coding 478
Swift Accessors 479
Key–Value Coding 481
Uses of Key–Value Coding 482
KVC and Outlets 483
Key Paths 484
Array Accessors 485
The Secret Life of NSObject 486

11. Cocoa Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489


Reasons for Events 490
Subclassing 490

Table of Contents | ix
Notifications 492
Receiving a Notification 493
Unregistering 495
Posting a Notification 496
Timer 497
Delegation 498
Cocoa Delegation 499
Implementing Delegation 500
Data Sources 502
Actions 503
The Responder Chain 506
Deferring Responsibility 507
Nil-Targeted Actions 508
Key–Value Observing 509
Swamped by Events 513
Delayed Performance 516

12. Memory Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519


Principles of Cocoa Memory Management 519
Rules of Cocoa Memory Management 521
What ARC Is and What It Does 522
How Cocoa Objects Manage Memory 522
Autorelease Pool 523
Memory Management of Instance Properties 525
Retain Cycles and Weak References 526
Unusual Memory Management Situations 529
Nib Loading and Memory Management 532
Memory Management of CFTypeRefs 533
Property Memory Management Policies 535
Debugging Memory Management Mistakes 537

13. Communication Between Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539


Visibility by Instantiation 540
Visibility by Relationship 542
Global Visibility 543
Notifications and Key–Value Observing 544
Model–View–Controller 545

A. C, Objective-C, and Swift. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

x | Table of Contents
Preface

On June 2, 2014, Apple’s WWDC keynote address ended with a shocking announce‐
ment: “We have a new programming language.” This came as a huge surprise to the
developer community, which was accustomed to Objective-C, warts and all, and
doubted that Apple could ever possibly relieve them from the weight of its venerable
legacy. The developer community, it appeared, had been wrong.
Having picked themselves up off the floor, developers immediately began to examine
this new language — Swift — studying it, critiquing it, and deciding whether to use it.
My own first move was to translate all my existing iOS apps into Swift; this was
enough to convince me that, for all its faults, Swift deserved to be adopted by new
students of iOS programming, and that my books, therefore, should henceforth
assume that readers are using Swift.
The Swift language is designed from the ground up with these salient features:
Object-orientation
Swift is a modern, object-oriented language. It is purely object-oriented: “Every‐
thing is an object.”
Clarity
Swift is easy to read and easy to write. Its syntax is clear, consistent, and explicit,
with few hidden shortcuts and minimal syntactic trickery.
Safety
Swift enforces strong typing to ensure that it knows, and that you know, what the
type of every object reference is at every moment.
Economy
Swift is a fairly small language, providing some basic types and functionalities
and no more. The rest must be provided by your code, or by libraries of code that
you use — such as Cocoa.

xi
Memory management
Swift manages memory automatically. You will rarely have to concern yourself
with memory management.
Cocoa compatibility
The Cocoa APIs are written in C and Objective-C. Swift is explicitly designed to
interface with most of the Cocoa APIs.
These features make Swift an excellent language for learning to program iOS.
The alternative, Objective-C, still exists, and you can use it if you like. Indeed, it is
easy to write an app that includes both Swift code and Objective-C code; and you may
have reason to do so. Objective-C, however, lacks the very advantages that Swift
offers. Objective-C agglomerates object-oriented features onto C. It is therefore only
partially object-oriented; it has both objects and scalar data types, and its objects have
to be slotted into one particular C data type (pointers). Its syntax can be difficult and
tricky; reading and writing nested method calls can make one’s eyes glaze over, and it
invites hacky habits such as implicit nil-testing. Its type checking can be and fre‐
quently is turned off, resulting in programmer errors where a message is sent to the
wrong type of object and the program crashes. It uses manual memory management;
the recent introduction of ARC (automatic reference counting) has alleviated some of
the programmer tedium and has greatly reduced the likelihood of programmer error,
but errors are still possible, and memory management ultimately remains manual.
Recent revisions and additions to Objective-C — ARC, synthesis and autosynthesis,
improved literal array and dictionary syntax, blocks — have made it easier and more
convenient, but such patches have also made the language even larger and possibly
even more confusing. Because Objective-C must encompass C, there are limits to
how far it can be extended and revised. Swift, on the other hand, is a clean start. If
you were to dream of completely revising Objective-C to create a better Objective-C,
Swift might be what you would dream of. It puts a modern, rational front end
between you and the Cocoa Objective-C APIs.
Therefore, Swift is the programming language used throughout this book. Neverthe‐
less, the reader will also need some awareness of Objective-C (including C). The
Foundation and Cocoa APIs, the built-in commands with which your code must
interact in order to make anything happen on an iOS device, are still written in C and
Objective-C. In order to interact with them, you have to know what those languages
would expect. For example, in order to pass a Swift array where an NSArray is
expected, you need to know what constitutes an object acceptable as an element of an
Objective-C NSArray.
Therefore, in this edition, although I do not attempt to teach Objective-C, I do
describe it in enough detail to allow you to read it when you encounter it in the docu‐
mentation and on the Internet, and I occasionally show some Objective-C code.

xii | Preface
Part III, on Cocoa, is really all about learning to think the way Objective-C thinks —
because the structure and behavior of the Cocoa APIs are fundamentally based on
Objective-C. And the book ends with an appendix that details how Swift and
Objective-C communicate with one another, as well as explaining how your app can
be written partly in Swift and partly in Objective-C.

The Scope of This Book


This book is actually one of a pair with my Programming iOS 10, which picks up
exactly where this book leaves off. They complement and supplement one another.
The two-book architecture should, I believe, render the size and scope of each book
tractable for readers. Together, they provide a complete grounding in the knowledge
needed to begin writing iOS apps; thus, when you do start writing iOS apps, you’ll
have a solid and rigorous understanding of what you are doing and where you are
heading. If writing an iOS program is like building a house of bricks, this book
teaches you what a brick is and how to handle it, while Programming iOS 10 hands
you some actual bricks and tells you how to assemble them.
When you have read this book, you’ll know about Swift, Xcode, and the underpin‐
nings of the Cocoa framework, and you will be ready to proceed directly to Program‐
ming iOS 10. Conversely, Programming iOS 10 assumes a knowledge of this book; it
begins, like Homer’s Iliad, in the middle of the story, with the reader jumping with all
four feet into views and view controllers, and with a knowledge of the language and
the Xcode IDE already presupposed. If you started reading Programming iOS 10 and
wondered about such unexplained matters as Swift language basics, the
UIApplicationMain function, the nib-loading mechanism, Cocoa patterns of delega‐
tion and notification, and retain cycles, wonder no longer — I didn’t explain them
there because I do explain them here.
The three parts of this book teach the underlying basis of all iOS programming:

• Part I introduces the Swift language, from the ground up — I do not assume that
you know any other programming languages. My way of teaching Swift is differ‐
ent from other treatments, such as Apple’s; it is systematic and Euclidean, with
pedagogical building blocks piled on one another in what I regard as the most
helpful order. At the same time, I have tried to confine myself to the essentials.
Swift is not a big language, but it has some subtle and unusual corners. You don’t
need to dive deep into all of these, and my discussion will leave many of them
unexplored. You will probably never encounter them, and if you do, you will
have entered an advanced Swift world outside the scope of this discussion. To
give an obvious example, readers may be surprised to find that I never mention
Swift playgrounds or the REPL. My focus here is real-life iOS programming, and
my explanation of Swift therefore concentrates on those common, practical

Preface | xiii
aspects of the language that, in my experience, actually come into play in the
course of programming iOS.
• Part II turns to Xcode, the world in which all iOS programming ultimately takes
place. It explains what an Xcode project is and how it is transformed into an app,
and how to work comfortably and nimbly with Xcode to consult the documenta‐
tion and to write, navigate, and debug code, as well as how to bring your app
through the subsequent stages of running on a device and submission to the App
Store. There is also a very important chapter on nibs and the nib editor (Interface
Builder), including outlets and actions as well as the mechanics of nib loading;
however, such specialized topics as autolayout constraints in the nib are post‐
poned to the other book.
• Part III introduces the Cocoa Touch framework. When you program for iOS, you
take advantage of a suite of frameworks provided by Apple. These frameworks,
taken together, constitute Cocoa; the brand of Cocoa that provides the API for
programming iOS is Cocoa Touch. Your code will ultimately be almost entirely
about communicating with Cocoa. The Cocoa Touch frameworks provide the
underlying functionality that any iOS app needs to have. But to use a framework,
you have to think the way the framework thinks, put your code where the frame‐
work expects it, and fulfill many obligations imposed on you by the framework.
To make things even more interesting, Cocoa uses Objective-C, while you’ll be
using Swift: you need to know how your Swift code will interface with Cocoa’s
features and behaviors. Cocoa provides important foundational classes and adds
linguistic and architectural devices such as categories, protocols, delegation, and
notifications, as well as the pervasive responsibilities of memory management.
Key–value coding and key–value observing are also discussed here.

The reader of this book will thus get a thorough grounding in the fundamental
knowledge and techniques that any good iOS programmer needs. The book itself
doesn’t show how to write any particularly interesting iOS apps, but it does constantly
use my own real apps and real programming situations to illustrate and motivate its
explanations. And then you’ll be ready for Programming iOS 10, of course!

Versions
This book is geared to Swift 3, iOS 10, and Xcode 8.
In general, only very minimal attention is given to earlier versions of iOS and Xcode.
It is not my intention to embrace in this book any detailed knowledge about earlier
versions of the software, which is, after all, readily and compendiously available in my
earlier books. The book does contain, nevertheless, a few words of advice about back‐
ward compatibility (especially in Chapter 9).

xiv | Preface
The Swift language included with Xcode 8, Swift 3, has changed very significantly
from its predecessor, Swift 2. A few important basic syntax changes were foreshad‐
owed in Swift 2.2 and Swift 2.3, but Swift 3 adds many more, plus “renamification”
has changed the names of many standard library and Cocoa methods, along with the
new Foundation “overlay” that removes the “NS” prefix from certain type names.
Fortunately, if you have existing Swift 2 code, Xcode 8 comes with a migrator that will
update your Swift 2 code to Swift 3 in a remarkably intelligent fashion. This book,
conversely, is totally incompatible with Swift 2 and doesn’t discuss it; for the most
part, I behave as if Swift 2 never existed. I do call out a few particularly noteworthy
Swift 3 innovations, but by no means all of them.
In this edition, I have dropped my earlier convention of referring to Cocoa methods
by their Objective-C name, because “renamification” has made it impossible to
deduce the Swift 3 name of an Objective-C method. Instead, I give the name in Swift,
as a function reference (as described in Chapter 2) — that is, the name plus the
parameter labels followed by colon in parentheses. Now and then, if a method is
already under discussion and there is no ambiguity, I’ll use the bare name. (In a few
places, such as Appendix A, where the Objective-C language is explicitly under dis‐
cussion, I naturally do still use Objective-C method names.)
Please bear in mind that Apple continues to make adjustments to the Swift language.
I have tried to keep my code up-to-date right up to the moment when the manuscript
left my hands; but if, at some future time, a new version of Xcode is released along
with a new version of Swift, some of the code in this book, and even some informa‐
tion about Swift itself, might be slightly incorrect. Please make allowances, and be
prepared to compensate.
Screenshots of Xcode were taken using Xcode 8 under OS X 10.11 El Capitan. I have
not upgraded my machine to macOS 10.12 Sierra, because at the time of this writing
it was too new to be trusted with mission-critical work. If you are braver than I am
and are running Sierra, your interface may naturally look very slightly different from
the screenshots, but this difference will be minimal and shouldn’t cause any confu‐
sion.

Acknowledgments
My thanks go first and foremost to the people at O’Reilly Media who have made writ‐
ing a book so delightfully easy: Rachel Roumeliotis, Sarah Schneider, Kristen Brown,
Dan Fauxsmith, Adam Witwer, and Sanders Kleinfeld come particularly to mind.
And let’s not forget my first and long-standing editor, Brian Jepson, whose influence
is present throughout.

Preface | xv
As in the past, I have been greatly aided by some fantastic software, whose excellences
I have appreciated at every moment of the process of writing this book. I should like
to mention, in particular:

• git (http://git-scm.com)
• SourceTree (http://www.sourcetreeapp.com)
• TextMate (http://macromates.com)
• AsciiDoc (http://www.methods.co.nz/asciidoc)
• Asciidoctor (http://asciidoctor.org)
• BBEdit (http://barebones.com/products/bbedit/)
• EasyFind (http://www.devontechnologies.com/products/freeware.html)
• Snapz Pro X (http://www.ambrosiasw.com)
• GraphicConverter (http://www.lemkesoft.com)
• OmniGraffle (http://www.omnigroup.com)

The book was typed and edited entirely on my faithful Unicomp Model M keyboard
(http://pckeyboard.com), without which I could never have done so much writing over
so long a period so painlessly. For more about my physical work environment, see
http://matt.neuburg.usesthis.com.

From the Programming iOS 4 Preface


A programming framework has a kind of personality, an overall flavor that provides
an insight into the goals and mindset of those who created it. When I first encoun‐
tered Cocoa Touch, my assessment of its personality was: “Wow, the people who
wrote this are really clever!” On the one hand, the number of built-in interface
objects was severely and deliberately limited; on the other hand, the power and flexi‐
bility of some of those objects, especially such things as UITableView, was greatly
enhanced over their OS X counterparts. Even more important, Apple created a partic‐
ularly brilliant way (UIViewController) to help the programmer make entire blocks
of interface come and go and supplant one another in a controlled, hierarchical man‐
ner, thus allowing that tiny iPhone display to unfold virtually into multiple interface
worlds within a single app without the user becoming lost or confused.
The popularity of the iPhone, with its largely free or very inexpensive apps, and the
subsequent popularity of the iPad, have brought and will continue to bring into the
fold many new programmers who see programming for these devices as worthwhile
and doable, even though they may not have felt the same way about OS X. Apple’s
own annual WWDC developer conventions have reflected this trend, with their
emphasis shifted from OS X to iOS instruction.

xvi | Preface
The widespread eagerness to program iOS, however, though delightful on the one
hand, has also fostered a certain tendency to try to run without first learning to walk.
iOS gives the programmer mighty powers that can seem as limitless as imagination
itself, but it also has fundamentals. I often see questions online from programmers
who are evidently deep into the creation of some interesting app, but who are stymied
in a way that reveals quite clearly that they are unfamiliar with the basics of the very
world in which they are so happily cavorting.
It is this state of affairs that has motivated me to write this book, which is intended to
ground the reader in the fundamentals of iOS. I love Cocoa and have long wished to
write about it, but it is iOS and its popularity that has given me a proximate excuse to
do so. Here I have attempted to marshal and expound, in what I hope is a pedagogi‐
cally helpful and instructive yet ruthlessly Euclidean and logical order, the principles
and elements on which sound iOS programming rests. My hope, as with my previous
books, is that you will both read this book cover to cover (learning something new
often enough to keep you turning the pages) and keep it by you as a handy reference.
This book is not intended to disparage Apple’s own documentation and example
projects. They are wonderful resources and have become more wonderful as time
goes on. I have depended heavily on them in the preparation of this book. But I also
find that they don’t fulfill the same function as a reasoned, ordered presentation of
the facts. The online documentation must make assumptions as to how much you
already know; it can’t guarantee that you’ll approach it in a given order. And online
documentation is more suitable to reference than to instruction. A fully written
example, no matter how well commented, is difficult to follow; it demonstrates, but it
does not teach.
A book, on the other hand, has numbered chapters and sequential pages; I can
assume you know views before you know view controllers for the simple reason that
Part I precedes Part II. And along with facts, I also bring to the table a degree of expe‐
rience, which I try to communicate to you. Throughout this book you’ll find me
referring to “common beginner mistakes”; in most cases, these are mistakes that I
have made myself, in addition to seeing others make them. I try to tell you what the
pitfalls are because I assume that, in the course of things, you will otherwise fall into
them just as naturally as I did as I was learning. You’ll also see me construct many
examples piece by piece or extract and explain just one tiny portion of a larger app. It
is not a massive finished program that teaches programming, but an exposition of the
thought process that developed that program. It is this thought process, more than
anything else, that I hope you will gain from reading this book.

Conventions Used in This Book


The following typographical conventions are used in this book:

Preface | xvii
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program ele‐
ments such as variable or function names, databases, data types, environment
variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter‐
mined by context.

This element signifies a tip or suggestion.

This element signifies a general note.

This element indicates a warning or caution.

Using Code Examples


Supplemental material (code examples, exercises, etc.) is available for download at
http://github.com/mattneub/Programming-iOS-Book-Examples.
This book is here to help you get your job done. In general, if example code is offered
with this book, you may use it in your programs and documentation. You do not
need to contact us for permission unless you’re reproducing a significant portion of
the code. For example, writing a program that uses several chunks of code from this
book does not require permission. Selling or distributing a CD-ROM of examples
from O’Reilly books does require permission. Answering a question by citing this
book and quoting example code does not require permission. Incorporating a signifi‐
cant amount of example code from this book into your product’s documentation does
require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “iOS 10 Programming Fundamentals
with Swift by Matt Neuburg (O’Reilly). Copyright 2017 Matt Neuburg,
978-1-491-97007-2.”

xviii | Preface
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at [email protected].

Safari® Books Online


Safari Books Online is an on-demand digital library that
delivers expert content in both book and video form from
the world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of plans and pricing for enterprise, government,
education, and individuals.
Members have access to thousands of books, training videos, and prepublication
manuscripts in one fully searchable database from publishers like O’Reilly Media,
Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que,
Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kauf‐
mann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders,
McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more
information about Safari Books Online, please visit us online.

How to Contact Us
Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://bit.ly/ios10-prog-fundamentals.
To comment or ask technical questions about this book, send email to bookques‐
[email protected].
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly

Preface | xix
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

xx | Preface
PART I
Language

This part of the book teaches the Swift language, from the ground up. The descrip‐
tion is rigorous and orderly. Here you’ll become sufficiently conversant with Swift to
be comfortable with it, so that you can proceed to the practical business of actual pro‐
gramming.

• Chapter 1 surveys the structure of a Swift program, both physically and concep‐
tually. You’ll learn how Swift code files are organized, and you’ll be introduced to
the most important underlying concepts of the object-oriented Swift language:
variables and functions, scopes and namespaces, object types and their instances.
• Chapter 2 explores Swift functions. We start with the basics of how functions are
declared and called; then we discuss parameters — external parameter names,
default parameters, and variadic parameters. Then we dive deep into the power
of Swift functions, with an explanation of functions inside functions, functions as
first-class values, anonymous functions, functions as closures, curried functions,
and function references and selectors.
• Chapter 3 starts with Swift variables — their scope and lifetime, and how they are
declared and initialized, along with features such as computed variables and set‐
ter observers. Then some important built-in Swift types are introduced, includ‐
ing Booleans, numbers, strings, ranges, tuples, and Optionals.
• Chapter 4 is all about Swift object types — classes, structs, and enums. It explains
how these three object types work, and how you declare, instantiate, and use
them. Then it proceeds to polymorphism and casting, protocols, generics, and
extensions. The chapter concludes with a discussion of Swift’s umbrella types,
such as Any and AnyObject, and collection types — Array, Dictionary, and Set
(including option sets).
• Chapter 5 is a miscellany. We start with Swift’s flow control structures for branch‐
ing, looping, and jumping, including error handling. Then I’ll explain how to
create your own Swift operators. The chapter concludes by describing Swift
access control (privacy), introspection (reflection), and memory management.
CHAPTER 1
The Architecture of Swift

It will be useful at the outset for you to have a general sense of how the Swift language
is constructed and what a Swift-based iOS program looks like. This chapter will sur‐
vey the overall architecture and nature of the Swift language. Subsequent chapters
will fill in the details.

Ground of Being
A complete Swift command is a statement. A Swift text file consists of multiple lines
of text. Line breaks are meaningful. The typical layout of a program is one statement,
one line:
print("hello")
print("world")

(The print command provides instant feedback in the Xcode console.)


You can combine more than one statement on a line, but then you need to put a sem‐
icolon between them:
print("hello"); print("world")
You are free to put a semicolon at the end of a statement that is last or alone on its
line, but no one ever does (except out of habit, because C and Objective-C require the
semicolon):
print("hello");
print("world");
Conversely, a single statement can be broken into multiple lines, in order to prevent
long statements from becoming long lines. But you should try to do this at sensible
places so as not to confuse Swift. For example, after an opening parenthesis is a good
place:

3
print(
"world")
Comments are everything after two slashes in a line (so-called C++-style comments):
print("world") // this is a comment, so Swift ignores it

You can also enclose comments in /*...*/, as in C. Unlike C, C-style comments can
be nested.
Many constructs in Swift use curly braces as delimiters:
class Dog {
func bark() {
print("woof")
}
}
By convention, the contents of curly braces are preceded and followed by line breaks
and are indented for clarity, as shown in the preceding code. Xcode will help impose
this convention, but the truth is that Swift doesn’t care, and layouts like this are legal
(and are sometimes more convenient):
class Dog { func bark() { print("woof") }}
Swift is a compiled language. This means that your code must build — passing
through the compiler and being turned from text into some lower-level form that a
computer can understand — before it can run and actually do the things it says to do.
The Swift compiler is very strict; in the course of writing a program, you will often try
to build and run, only to discover that you can’t even build in the first place, because
the compiler will flag some error, which you will have to fix if you want the code to
run. Less often, the compiler will let you off with a warning; the code can run, but in
general you should take warnings seriously and fix whatever they are telling you
about. The strictness of the compiler is one of Swift’s greatest strengths, and provides
your code with a large measure of audited correctness even before it ever starts run‐
ning.

The Swift compiler’s error and warning messages range from the insightful to the
obtuse to the downright misleading. You will often know that something is wrong
with a line of code, but the Swift compiler will not be telling you clearly exactly
what is wrong or even where in the line to focus your attention. My advice in
these situations is to pull the line apart into several lines of simpler code until you
reach a point where you can guess what the issue is. Try to love the compiler
despite the occasional unhelpful nature of its messages. Remember, it knows
more than you do, even if it is sometimes rather inarticulate about its knowledge.

4 | Chapter 1: The Architecture of Swift


Everything Is an Object?
In Swift, “everything is an object.” That’s a boast common to various modern object-
oriented languages, but what does it mean? Well, that depends on what you mean by
“object” — and what you mean by “everything.”
Let’s start by stipulating that an object, roughly speaking, is something you can send a
message to. A message, roughly speaking, is an imperative instruction. For example,
you can give commands to a dog: “Bark!” “Sit!” In this analogy, those phrases are
messages, and the dog is the object to which you are sending those messages.
In Swift, the syntax of message-sending is dot-notation. We start with the object; then
there’s a dot (a period); then there’s the message. (Some messages are also followed by
parentheses, but ignore them for now; the full syntax of message-sending is one of
those details we’ll be filling in later.) This is valid Swift syntax:
fido.bark()
rover.sit()
The idea of everything being an object is a way of suggesting that even “primitive” lin‐
guistic entities can be sent messages. Take, for example, 1. It appears to be a literal
digit and no more. It will not surprise you, if you’ve ever used any programming lan‐
guage, that you can say things like this in Swift:
let sum = 1 + 2

But it is surprising to find that 1 can be followed by a dot and a message. This is legal
and meaningful in Swift (don’t worry about what it actually means):
let s = 1.description

But we can go further. Return to that innocent-looking 1 + 2 from our earlier code.
It turns out that this is actually a kind of syntactic trickery, a convenient way of
expressing and hiding what’s really going on. Just as 1 is actually an object, + is
actually a message; but it’s a message with special syntax (operator syntax). In Swift,
every noun is an object, and every verb is a message.
Perhaps the ultimate acid test for whether something is an object in Swift is whether
you can modify it. An object type can be extended in Swift, meaning that you can
define your own messages on that type. For example, you can’t normally send the say-
Hello message to a number. But you can change a number type so that you can:
extension Int {
func sayHello() {
print("Hello, I'm \(self)")
}
}
1.sayHello() // outputs: "Hello, I'm 1"

Everything Is an Object? | 5
In Swift, then, 1 is an object. In some languages, such as Objective-C, it clearly is not;
it is a “primitive” or scalar built-in data type. So the distinction being drawn here is
between object types on the one hand and scalars on the other. In Swift, there are no
scalars; all types are ultimately object types. That’s what “everything is an object”
really means.

Three Flavors of Object Type


If you know Objective-C or some other object-oriented language, you may be sur‐
prised by Swift’s notion of what kind of object 1 is. In many languages, such as
Objective-C, an object is a class or an instance of a class (I’ll explain later what an
instance is). Swift has classes, but 1 in Swift is not a class or an instance of a class: the
type of 1, namely Int, is a struct, and 1 is an instance of a struct. And Swift has yet
another kind of thing you can send messages to, called an enum.
So Swift has three kinds of object type: classes, structs, and enums. I like to refer to
these as the three flavors of object type. Exactly how they differ from one another will
emerge in due course. But they are all very definitely object types, and their similari‐
ties to one another are far stronger than their differences. For now, just bear in mind
that these three flavors exist.
(The fact that a struct or enum is an object type in Swift will surprise you particularly
if you know Objective-C. Objective-C has structs and enums, but they are not objects.
Swift structs, in particular, are much more important and pervasive than Objective-C
structs. This difference between how Swift views structs and enums and how
Objective-C views them can matter when you are talking to Cocoa.)

Variables
A variable is a name for an object. Technically, it refers to an object; it is an object
reference. Nontechnically, you can think of it as a shoebox into which an object is
placed. The object may undergo changes, or it may be replaced inside the shoebox by
another object, but the name has an integrity all its own. The object to which the vari‐
able refers is the variable’s value.
In Swift, no variable comes implicitly into existence; all variables must be declared. If
you need a name for something, you must say “I’m creating a name.” You do this with
one of two keywords: let or var. In Swift, declaration is usually accompanied by ini‐
tialization — you use an equal sign to give the variable a value immediately, as part of
the declaration. These are both variable declarations (and initializations):
let one = 1
var two = 2

6 | Chapter 1: The Architecture of Swift


Once the name exists, you are free to use it. For example, we can change the value of
two to be the same as the value of one:
let one = 1
var two = 2
two = one

The last line of that code uses both the name one and the name two declared in the
first two lines: the name one, on the right side of the equal sign, is used merely to refer
to the value inside the shoebox one (namely 1); but the name two, on the left side of
the equal sign, is used to replace the value inside the shoebox two. A statement like
that, with a variable name on the left side of an equal sign, is called an assignment,
and the equal sign is the assignment operator. The equal sign is not an assertion of
equality, as it might be in an algebraic formula; it is a command. It means: “Get the
value of what’s on the right side of me, and use it to replace the value of what’s on the
left side of me.”
The two kinds of variable declaration differ in that a name declared with let cannot
have its value replaced. A variable declared with let is a constant; its value is assigned
once and stays. This won’t even compile:
let one = 1
var two = 2
one = two // compile error

It is always possible to declare a name with var to give yourself the most flexibility,
but if you know you’re never going to replace the initial value of a variable, it’s better
to use let, as this permits Swift to behave more efficiently — so much more effi‐
ciently, in fact, that the Swift compiler will actually call your attention to any case of
your using var where you could have used let, offering to change it for you.
Variables also have a type. This type is established when the variable is declared and
can never change. For example, this won’t compile:
var two = 2
two = "hello" // compile error

Once two is declared and initialized as 2, it is a number (properly speaking, an Int)


and it must always be so. You can replace its value with 1 because that’s also an Int,
but you can’t replace its value with "hello" because that’s a string (properly speaking,
a String) — and a String is not an Int.
Variables literally have a life of their own — more accurately, a lifetime of their own.
As long as a variable exists, it keeps its value alive. Thus, a variable can be not only a
way of conveniently naming something, but also a way of preserving it. I’ll have more
to say about that later.

Variables | 7
Random documents with unrelated
content Scribd suggests to you:
"Sinun täytyy säilyttää rohkeutesi, Mercy. Minä puhuin ankarasti
sinulle tässä yhtenä iltana, mutta se on ohi nyt, uskothan sen?"

"Oi, miksi sinä jätit minut yksin?" valitti tyttö.

"Vaiti, Mercy. Sinun asiasi kääntyvät vielä hyväksi", sanoi Hugh ja


hänen omatkin silmänsä kävivät sumeiksi, mutta sydän oli katkera.
Eikö hän ollut juuri äsken vihassaan sanonut, että intohimo on
tämän maailman pahahenki? Hän tahtoi surussaankin sanoa samaa.
Tuon tytön yksinkertainen sydän rakasti häntä aivan yhtä paljon kuin
hänen kiihkeämpi sielunsa rakasti Gretaa. Hän oli rikkonut häntä
vastaan. Mutta se oli pikku asia. Tytön viha kärsimänsä vääryyden
vuoksi on pian asettunut ja hänen kanssaan kyllä tulee, toimeen.

"Mikä sinut tänne on tuonut, Mercy?"

"Eräs sisarista — ne käyvät sairaiden luona — eräs heistä kävi


siinä talossa, jossa minä asuin ja minä kuulin, että he joskus ottavat
kodittomia tyttöjä luostariin. Ja minä ajattelin, että minä olin koditon
nyt ja — ja —"

"Onneton pikku nainen!"

"Minä tulin toissa iltana, mutta näin sinun veljesi Paulin kävelevän
täällä, ja menin pois."

"Paulin?"

"Sitten minä tulin eilen illalla, mutta hän oli täällä taas ja minun
täytyi vieläkin palata. Sentähden minä tänään tulin aikaisemmin eikä
häntä ollut täällä. Mutta juuri kun minä aioin soittaa ja sanoa, että
minä olen koditon ja että minun silmäni tulevat yhä pahemmiksi,
jokin tuntui sanovan minulle, että ne kysyvät, eikö minulla ole isää ja
minkätähden minä olen jättänyt hänet. Silloin minä en voinut soittaa
— ja silloin minä toivoin, että voisin kuolla — niin, jos voisin kuolla ja
unohtaa eikä koskaan enää aamulla herätä —"

"Vaiti, Mercy. Sinun täytyy palata takaisin isäsi luo."

"Ei, ei, ei!"

"Kyllä, ja minä tulen sinun kanssasi."

Seurasi äänettömyys. Sameat silmät tuijottivat suoraan Hughin


kasvoihin. Kevyt hymy kohtasi hänen katsettaan.

"Ah!"

Hänen sielussaan kangasti ihanana se päivä, jolloin hän käsi


kädessä rakastettunsa kanssa saapuisi vuoristoon hylättyyn kotiinsa
ja pyyhkisi pois isänsä kyyneleet. Nyt hän kuitenkin oli suuren
kaupungin pimeällä kadulla ja hänen kotinsa oli äärettömän
kaukana.

Hugh naurahti sielussaan toisenlaiselle kuvalle. Hullu oikku johti


hänen mieleensä ajatuksen, että kaikki hänen kuohuvat intohimonsa
olisivat asettuneet ja hän näki itsensä tämän mitättömän naisen
tyytyväisenä, kotirakkaana ja kunnioitettuna aviomiehenä.

"Oliko Paul yksin, kun sinä hänet näit?" kysyi Hugh.

"Oli. Ja sanotko sinä niille kaikki?"

Tytön sivulle-kääntyneeseen katseeseen levähti kaukainen,


harhaileva ilme.

"Mercy, minä toivoisin, että sinä tekisit jotakin minun hyväkseni."


"Kyllä, kyllä."

Onnesta sykähtäen Mercy katsahti salaa häneen,

Hugh kohotti tytön päätä kootakseen hänen harhailevat


ajatuksensa.

"Paul tulee varmaan tänäkin iltana. Minä tahdon, että sinä odotat
ja puhuttelet häntä."

"Kyllä, kyllä, mutta eikö hän kysele minulta vaikka mitä?"

"Mitä se tekee? Vastaa kaikkiin hänen kysymyksiinsä. Älä vain


sano, että minä olen pyytänyt sinua puhuttelemaan häntä. Sano
hänelle — muistatko sen? Kuunteletko sinä? Katso minua silmiin,
pikku vaimo."

"Kyllä, kyllä."

"Sano hänelle, että herra Christian, kirkkoherra Christian,


tiedäthän — on tullut Lontooseen ja tahtoo tavata häntä heti. Sano
hänelle, että hän on etsinyt häntä Hallituskadun hotellista, mutta kun
ei ole tavannut, niin on nyt Hendonin kapakassa. Muistatko sen?"

"Kyllä."

"Mihin sinä aioit mennä, Mercy — takaisin ystäväisi luo?"

"En. Mutta tuleeko hän varmaan tänä iltana?"

"Epäilemättä. Mihin aikaan hän oli täällä eilen illalla?"

"Kello kymmenen."
"Nyt se on jo paljon yli yhdeksän. Pyydä häntä menemään heti
Hendoniin ja kun hän lähtee, tule sinä hänen kanssaan.
Ymmärrätkö?"

"Kyllä."

"Älä unohda, tänä iltana. Huomeniltana se ei enää sovi. Ellei hän


tule, sinun kuitenkin täytyy tulla Hendoniin kertomaan minulle. Minä
olen siellä. Älä sano hänelle sitä — kuuletko?"

Tyttö nyökkäsi nöyrästi.

"Ja nyt hyvää yötä tunniksi tai pariksi, sinä pikku lemmikki."

Hän asteli tiehensä, ja Mercy jäi yksin synkän luostarin edustalle.


Mutta hän ei kuitenkaan ollut yksin. Vasta herännyt unelma täytti
hänen rintansa, ja kirkas valo kajasti hänen sielussaan.
XIV LUKU.

Hugh Ritson astui kiireesti Dean Yardin läpi Sanctuarya kohden. Kun
hän kääntyi Parlamentin kadulle, puolikuu kohosi Westminster Hallin
yli. Mutta yö oli vieläkin pimeä.

Hän kulki Trafalgar Squaren läpi Heinätorille. Kadut siellä olivat


täynnä. Joukko joukon perään kulki ohi — surkeita miesten ja
naisten varjoja, enimmäkseen kurjia, jotka tähän aikaan maleksivat
pitkin katuja: vanhoja miehiä, joiden sielu oli jo monia vuosia sitten
kuollut; turmelus levisi heidän hengityksessään myrkyttäen jokaisen
sanan, ja kuin ruttotauti heidän tirkistävä katseensa tartutti kaiken,
mihin se sattui. Heidän rinnallaan hyppivät nuoret tytöt kuin
järjettömät, elukat kuihtuneet nuoruuden ruusut kasvoillaan, mutta
sydämessä pistävät okaat. Heillä ei ollut muuta tietä kuin tämä — tai
toinen: heittäytyä Thamesiin ja hautautua kuoleman aaltoihin tai
koettaa vielä pysytellä lyhyt hetkinen elämän mutalätäkön pinnalla.

Nauraen koska eivät voineet enää itkeä, nauraen, koska heidän


sielunsa oli jo kuollut, nauraen omantuntonsa raunioilla sille
murhenäytelmälle, johon osalliseksi jokaisen hänen huvitteluhalunsa
oli vienyt, he sipsuttivat, löntystivät tai hoipertelivat pitkin katuja.
Lamput hohtivat heidän päidensä päällä ja kaikkien yllä paistoi kuu
puoli-hämäränä.

Kun Hugh Ritson joutui Heinätorille, hänen horjuva askelensa kävi


yhä epävarmemmaksi ja huojuen hän kulki eteenpäin. Eräs nainen,
joka vaanien ja odotellen oli seurannut muutamien askelten päässä
hänestä, huomasi tämän ja ollen olevinaan huomaamatta häntä
huudahti pilkallisesti nauraen: "Mikäs tuo on — mies vai peikko?"

Kuinka villi ja vihlova olikaan tämä yönsydän!

Joukon läpi tunkeutui eteenpäin eräs mies, joka ei näyttänyt


tajuavan tätä riehuvaa hulluutta eikä ilotonta huvia — pitkä mies,
joka harppasi kuin jättiläinen kääpiöiden keskellä, tylsät silmät eteen
tuijottaen ja valkeat kasvot ilmeettöminä. Hugh Ritson näki hänet.
He sivuuttivat toisensa parin askelen päästä, mutta tuntemattomina.
Toinen kulki määrää vailla sokeassa tuskassansa pyhän Margaretin
luostarille ja toinen suuntasi askelensa Hendonin vanhaan
kapakkaan.

*****

Tuntia myöhemmin Hugh Ritson seisoi Haukka-Haikaran


kapakkahuoneessa.
Hän oli tehnyt päätöksensä. Se oli purkamaton ja suunnitelma oli
valmis.

"Onko ketään hänen luonaan?" hän kysyi kapakan emännältä


astellen portaille päin.

"Ei minun tietääkseni, herra, mutta hän näyttää niin levottomalta


ja kuin olisi poissa suunniltaan, enkä minä tiedä, miten ymmärtää
—"

Hugh Ritson pysäytti hänen kielevän lavertelunsa. "Minä olen


löytänyt tytön. Hän tulee takaisin teidän luoksenne, rouva Drayton.
Jos se herra, joka jätti nämä tavarat, saapuu hänen mukanansa,
viekää hänet poikanne makuuhuoneeseen ja sanokaa, että se
henkilö, jota hän haluaa puhutella, on saapunut ja tulee heti paikalla
hänen luokseen."

Tämän sanottuaan hän meni portaita ylös. Sieltä hän huudahti


alas rouva Draytonille: "Sinä hetkenä, kun hän on huoneessa, tulkaa
ilmoittamaan minulle." Hetkistä myöhemmin hän vielä lisäsi:

"Missä on tämän oven avain? Antakaa se minulle."

Kapakan emäntä lyntysti ylös vieden Draytonin makuuhuoneen


avaimen: huone oli tyhjä ja ovi oli auki, Hugh Ritson koetti avainta
lukkoon ja näki, että se käy hyvin. "Hyvä on", hän sanoi tyytyväisellä
äänellä.

Vanha vaimo lähti lenksuttamaan takaisin. Hugh seisoi


ajatuksissaan painunein päin ja etusormensa kynsi kasvoissa kiinni.

"Sivumennen, rouva Drayton", hän sanoi, "te voi sitte antaa tytön
joskus auttaa itseänne."

"Varjelkoon, herra, enhän minä voi koskaan vaivata häntä, hän


kun on vieras."

"Lörpötystä, rouva Drayton. Hän on nuori ja pirteä, ja teidän


parhaat päivänne ovat jo ohi, tiedättehän, Miten teidän rintanne on
tänään — parempi?"
"Kiitoksia vain, enhän voi sanoa, että se olisi paljoa parempi, kiitos
vain kysymästä, herra", ja pitkällinen yskänpuuska todisti vaimon
sanat oikeiksi.

"Ah, tuo on pahan merkki, eukko hyvä."

"Niin, niin on, herra. Eikä mitään myötätuntoa, herra — kaikista


vähimmin siltä, jolta äiti toivoisi — ei ainoatakaan sanaa."

"Ajatelkaahan. Eikö ole mitään, mitä tyttö voisi tehdä, kun hän
tulee — ei mitään palvelusta, ei askareita?"

"No, herra, tuota, kyllähän kellarissa olisi järjestämistä, kun tuo


pojan veikale, jonka pitäisi huoltaa siitä, on niin saamaton, kuten
minä selitin —"

"Aivan oikein, rouva Drayton. Lähettäkää tyttö sinne heti, kun hän
tulee ja pitäkää siellä maatamenoon asti."

"Kiitoksia paljon, herra. Olkaa varma, että minusta! herra tekee


niin hyvin ja viisaasti, kun pitää huolta ihan syyttömästi."

Kapakan emäntä linkutti alas keikutellen kiitollisena vanhaa


kalloansa. Viisas herrasmies pisti rouva Draytonilta saamansa
avaimen oveen ulkopuolelta jättäen sen siihen ja nousi sitten
ullakolle, jossa koputti päätykopin oveen. Aluksi ei kuulunut mitään
vastausta. Raskas askelten ääni kuitenkin ilmaisi, että sisällä oli joku.
"Tulkaa ja avatkaa ovi", sanoi Hugh kärsimättömästi.

Ovi avautui varovasti. Drayton seisoi sen takana, ja Hugh Ritson


astui sisään. Huoneessa ei ollut valoa. Pitkän kynttilän hiiltynyt sydän
ilmaisi kuitenkin, että se juuri oli sammutettu ja pistävä rasvan haju
täytti ilman.
"Te pidätte nähtävästi varanne", sanoi Hugh. "Koettakaapas saada
valoa."

Drayton laskeusi pimeässä polvilleen, kopeloitsi lattialta tulitikkuja


ja sytytti kynttilän uudestaan. Hän oli paitahihasillansa.

"Eikö ole kylmä ilman takkia, vai?" sanoi Hugh. Hänen huulensa
vääntyivät irviin.

Vastaamatta Drayton meni patjan luo, joka oli lattialla hämärässä


nurkassa, nosti sitä ja otettuaan takkinsa sen alta veti sen yllensä.
Se oli hänen revitty ulsterinsa.

Hugh Ritson seurasi Draytonin liikkeitä ja naurahti huolettomasti.


"Teidänlaisenne miehet ovat aina? varovaisia väärällä paikalla", hän
sanoi. "Jos ne kerran saavat teidät kiinni, ei kestä kauan, ennenkuin
ne löytävät — takkinne." Viimeinen sana lausuttiin merkitsevällä
äänenpainolla.

"Saatana, jos minä en sitä polta sopivassa tilaisuuressa", mutisi


Drayton. Hänen käytöksensä oli juro ja masentunut.

"Ei, sitä te ette saa tehdä", sanoi Hugh katsellen häntä


suurellisesti. Ylinen oli tyhjä lukuunottamatta patjaa ja vilttiä, joka oli
melkein koossa sen toisessa päässä ja paria kolmea lautasta, jotka
olivat lattialla kuivuneine ruoanjätteineen. Se oli matala huone,
johon vuoliaisten raosta ja seinistä päivä näkyi. Muuta akkunaa ei
ollutkaan. Seiniä oli kai joskus tukittu, mutta riiveet olivat irtautuneet
ja roikkuivat vain toisesta päästään kiinni.

"Onkos kuulunut mitään?" murahti Drayton äreästi.

"On. Minä ilmoitin poliisikersantille, että luulin päässeeni jäljille."


"Mitä? Ette!"

Kaksi miestä katsoi toisiinsa — Drayton epäilevästi vaanien ja


Hugh
Ritson tyytyväisenä ja hyvätuulisesti.

"Minä sanon teille: minua ei oteta kiinni noin vain lemmessä",


sanoi
Drayton koettaen säilyttää tyyneytensä.

Hugh Ritson ei vastannut muuta kuin hymähti. Kun hän katsahti


Draytonin kasvoihin, hänestä tuntui, ettei yksikään ihminen koskaan
ole ollut sellaisessa tilanteessa kuin hän oli tällä hetkellä. Tuossa oli
mies, joka oli Gretan velipuoli ja hänen miehensä ilmetty kuva.
Tuossa oli mies, joka vakavista epäilyksistään huolimatta ei tiennyt
omaa syntyperäänsä. Tuossa oli mies, jota uhkasi ankara rangaistus.
Hugh Ritson hymyili ajatellessaan, että hän aikoi juuri tehdä tämän
miehen siksi, mikä hän oli.

"Drayton", hän sanoi, "minä aion olla teidän ystävänne tässä


asiassa."

"Sanon teille vielä, että vain se on minun ystäväni, joka auttaa


minua saavuttamaan onneni."

"Te saavutatte sen, Drayton, vielä tänä yönä. Kuunnelkaa minua.


Se mies, jota sanotaan minun veljekseni Paul Ritsonin nimellä, ei ole
minun isäni poika. Hän on minun äitini ja erään toisen miehen poika
ja hänen oikea nimensä on Paul Lowther."

"Minä en välitä siitä, mikä hänen oikea nimensä on, enempää kuin
siitäkään, mikä on väärä. Se ei merkitse minulle mitään, sanon minä,
ja sillä hyvä."

"Eikö teille merkitsisi mitään saada periä viisituhatta puntaa?"

"Mitä?"

"Paul Lowther on sellaisen summan perijä. Mitä te sanotte, jos


minä panisin teidät Paul Lowtherin sijalle ja te saisitte Paul Lowtherin
perinnön?"

"Häh? Ja tuo onni olisi saatavissa — ja miten?"

"Kuten olen sanonut teille aikaisemmin."

Kuului hiljaista ratinaa, sellaista kuin syntyy, kun rotta nakertaa


tietänsä jauholaariin.

"Mitä se on?" sanoi Drayton kasvot valahtaen valkeiksi ja


levottomat silmät pelokkaina oveen kääntyen. "Avain pantiin oveen",
hän kuiskasi.

"Turhaa, eikö teidän oma avaimenne ole sisäpuolella?" hymyili


Hugh
Ritson.

Drayton painoi päänsä alas häveten omaa pelkoansa. "Minä tierän


— minä en ole sitä unohtanut", hän mutisi tukahduttaen turhan
hämminkinsä.

"Sääli on, että te voitte täällä joutua kiinni sen sijaan, että olisitte
vapaana ja turvassa", sanoi Hugh.

"Niin on", mutisi Drayton.


"Ja mennä eliniäksenne kuritushuoneeseen, kun joku toinen voisi
sen yhtä hyvin tehdä teidän puolestanne", lisäsi Hugh pirullisesti
hymyillen.

"Minulla ei ole mitään sitä järjestelyä vastaan. Mitä tuo on?"


Drayton lyyhistyi kokoon. Lahonneesta katosta tipahti päreen
kappale, kun tuuli oli sitä aikansa heilutellut. Hugh Ritsonin
ainoakaan lihas ei värähtänyt. Vain halveksiva sivukatse ilmaisi
hänen tyytyväisyyttään nähdessään tämän rikollisen olennon pelon.

"Asianajaja, jonka huollettavana tämä jälkisäädös on, on minun


ystäväni ja toverini", hän sanoi hetkisen vaitiolon jälkeen. "Sielläpäin
meidän ei ole vaikea järjestää tätä asiaa. Minun äitini on —. No niin,
hän on mennyt. Ei ole ketään, joka voi epäillä teitä. Jos teillä on
vähänkään rohkeutta, on tie selvä."

"Mitäs hän sanoo?"

"Greta? Hänestä tulee teidän vaimonne."

"Minun vaimoni?"

"Nimellisesti. Teidän täytyy purkaa koko liitto, kuten sanoin teille,


selittämällä: 'Minä, jonka olette, tunteneet Paul Ritsonin nimellä,
olenkin Paul Lowther ja siten olen sen naisen velipuoli, jonka kanssa
olen vihitty avioliittoon. Tämän tosiasian sain selville heti Lontooseen
tultuani. Minä tuon tämän naisen takaisin sinne, mistä olen hänet
löytänytkin ja vaadin, että avioliitto — joka ei ole mikään avioliitto —
puretaan. Minä luovutan oikealle perilliselle, Hugh Ritsonille, kaikki
Allan Ritsonin maatilat ja vaadin, että minulle suoritetaan isäni,
Robert Lowtherin, jälkisäädöksellään määräämä summa.' Siinä
kaikki, mitä teidän tulee sanoa ja tehdä, ja kaikki kunnioittavat ja
ylistävät teitä rehellisenä ja oikeudenmukaisena miehenä."

"Se on hyvin ymmärrettävää, mutta mitäs hänestä?"

"Hän on silloin Paul Drayton ja pahantekijä."

Drayton nauraa hykersi. "Ja mitäs nainen sanoo?"

"Kun mies on kiinni ja varmassa tallessa, naisesta ei ole suurta


lukua."

"Silloin minä tulen olemaan Paul Lowther!"

"Teidän tulee olla olevinanne Paul Lowther."

"Sanoin teille jo aikaisemmin, ettei tämä mahru mun kallooni, ja


siltä se vieläkin tuntuu", sanoi Drayton kynsien päätänsä.

"Te saatte kyllä aikaa oppia läksynne. Te onnistutte mainiosti",


tyynnytteli Hugh. "Kuitenkin —"

Sillä hetkellä Draytonin silmät olivat kääntyneet muutamaan


rakoon, josta tähti pilkisti yliselle.

"Katsokaa tuonne", hän kuiskasi.

"Mitä?"

"Jonkun naama katolla."

Hugh Ritson kohotti kynttilän ja tarkasti osoitettua paikkaa. "Mikä


naama?" hän kysyi halveksivasti.
Drayton häpesi turhaa pelkoansa ja painoi päänsä alas.

Alasjohtavilta portailta kuului sipsuttavia askeleita. Drayton käänsi


katseensa sivulle ja kuunteli. "Vanha eukko", hän mutisi. "Mitä nyt?
Illallinen, luullakseni."
XV LUKU.

Samana hetkenä uusi tulija ilmestyi kapakkahuoneeseen. Hän oli


vanha, pörrökulmainen ja ryppykasvoinen mies, kutistunut olento,
jolla oli jäljellä vain suuri päänsä, mutta senkin musta tukka oli
muuttunut harmaaksi. Se oli Gubblum Oglethorpe. Vuoriston
kerjäläinen oli kulkenut etelään ostamaan säämiskänahkoja. Hän oli
kerännyt niitä suuren nipun, jota hän kantoi kuin koria
käsivarressaan.

Aina Newlannin häistä, kolme päivää sitten, Gubblumin vilkas


mielikuvitus ei ollut saanut rauhaa, vaan hänen täytyi koettaa saada
selville, kuka oli se Paul Ritsonin näköinen mies, jonka hän kerran oli
nähnyt Hendonissa. Hän oli päättänyt kerta kaikkiaan saada selville
tämän merkillisen asian. Niinpä hän heti ensimmäisellä Lontoon-
matkallansa päätti yöpyä juuri samaan kapakkaan; ehkä salaisuus
jotenkin silloin selviäisi.

"Kuinkas hurisee?" hän kysyi tervehtien sisäänastuessaan.


Yläkertaan lähtiessään rouva Drayton oli jättänyt juoksupojan
pitämään kapakasta huolta. Tämä oli hölmönnäköinen
kuusitoistavuotias tolvana, nimeltään Jabez.
Jabez kohotti hitaasti silmänsä oluttuopeista, joita oli pesemässä,
ja leveä hymy ilmestyi hänen kasvoillensa. Ilmeisesti tulija oli joku
maanmoukka.

"Kylmä yö, huh! Pureva kuin äitipuolen hengitys", puheli Gubblum


heittäen kimpun kädestänsä ja vetäytyen takan ääreen.

Hymy Jabezen kasvoilla yhä levisi ja hän alkoi nauraa hohottaa.

"Mitäs sinä kikatat, häh?" sanoi Gubblum. "Minä sanon, että ilma
on kuuma, jos tahron. Sinä et siitä mitään tierä, vai?"

Jabez nauroi kohti kurkkuansa. Varmaankin tuo moukka oli hullu.

"Mitähän tuo vietävä hohottanee?" ajatteli Gubblum. Sitten


ääneen: "Ai, poikaseni, annappa mulle jotakin suunavausta."

Jabez tunsi tällaisen puhetavan asettavan hänen naurutautiansa.


Hän alkoi täyttää tuoppia. Juoksupojan liikkeet olivat ihan yhtä
nopeat kuin matavan kilpikonnan.

"Hän on läpiliipattu lurjus, tuo", ajatteli Gubblum. "Hän polskuttaa


kuin ankka vesialtaassa."

"Voinko minä saara täällä yösijan?" hän kysyi, kun Jabez oli tuonut
hänelle oluen.

Silloin kiusallinen hymy pojan kasvoilla lientyi puheeksi.

"Mää en tiärä yösijoist'", hän sanoi, "mutt' voitte ehkä saarakkin —


he, he, he! Mää kysyn rouvalt — he, he, heh!"

"Rouvalt'? Eiks' sull' sitten herraa olekaan?" kysäisi Gubblum.


Nyt oli Jabezia varoitettu, ettei mitenkään antaisi isännän suhteen
panna itseään pussiin, vaan joka kerta, kun isännästä tulee kysymys,
hänen tulee olla mykkä kuin hauta. Siksipä hän vastaukseksi
kerjäläisen kysymykseen pudisti viisasta päätään ja näytti
tietämättömältä ja hämmästyneeltä.

"Ei? Ja kuinkas kauan olet ollut täällä?"

"Pääsiäisenä kolme vuotta", vastasi Jabez.

"Ja kuinkas kauan sanoit rouvan olleen täällä?"

"Rouvan? Mää kuulin isän sanovan, ett' rouva Drayton on pitänyt


Haukka-Haikaraa kaksikymment' viis' vuotta."

"Kaksikymmentä viisi! Silloin otaksun, ettei herra ollut kuin pikku


lapsi, kun hän tuli tänne", sanoi Gubblum.

"Ehk'ei ollut", myönsi Jabez. Sitten huomaten, että oli


varovaisuuden niin huomaamatta unohtanut, hän ankarasti väitti,
ettei hänellä herraa ollut.

"Vaikea on syörä kaffelilla kirnupiimää", ajatteli Gubblum. Hän


koetti käyttää lusikkaa.

"Kattos, poikasein, tahroks', että lainaan sulle tään shillingin?"

Jabez irvisti ja puristi lihavaan nyrkkiinsä saamansa rahan.

"Minä tunsin kerran miehen, joka väitti, että sinun isäntäsi oli
jymäyttänyt muuatta pitkätukkaista", sanoi Gubblum. "Minä ajattelin,
että hän itse oli jymäyttänyt. Mutta kun minä sanoin sen hänelle,
hän tarttui minua niskasta kiinni ja nutisti katuun, ja kaikki vain siksi,
että minä puolustin sinun isäntääsi."

"Mutta minulla ei ole isäntää", väitti Jabez.

"Silloin minä ratsastin ponipahallani, mutta nyt minä saan lyntätä


jalan", jatkoi Gubblum välittämättä pojan kokeesta näyttää
mahdollisimman viattomalta. "Samalla kertaa minä huusin hänelle:
'Hyvää huomenta, herra Paul!' ohikulkiessani."

"Sittenhän te tierätte hänen nimensäkin?" kysyi Jabez avaten


uniset silmänsä selko selälleen.

"'Herra Paul on mieronkiertäjä', sanoi eräs katupoika. 'Niin on',


sanon minä, 'tierän vallan hyvin.' Ah, minä muistan sen ihan kuin se
olisi tapahtunut eilen. Minä katsoin taakseni ja täällä hän seisoi
kapakan ovella kaivaen nenäänsä sormellansa. Niin juuri, niin hän
teki."

Jabez tunsi tällä hetkellä omantuntonsa tavattoman valppaaksi.


"Mutta minulla ei ole", hän väitti uudestaan.

"Mitä ei ole?"

"Herraa."

"Se on valhe, poikaseni, sillä hän näyttää antaneen sinulle mustan


silmän — ja se oli oikein — estääkseen sinua pistämästä nenääsi
joka paikkaan."

Tämän jälkeen Gubblum istui runsaan puolen tuntia aivan ääneti.


Rouva Drayton tuli alas ja järjesti niin, että Gubblum saisi nukkua
yönsä talossa. Hänen vuoteensa oli pienessä huoneessa toisessa
kerroksessa talon takaosassa, ja sen ovi oli ullakolle johtavien
portaitten juurella.

Gubblum lähti ylös väittäen olevansa väsynyt ja pyysi näyttämään,


missä hänen huoneensa on. Jabez sytytti kynttilän, ja niin he
yhdessä lähtivät.

"Mihinkäs tuo vie?" kysyi Gubblum osoittaen porrasta, joka oli


hänen ovensa vieressä.

"En tierä", murahti Jabez nyrpeissään. Hän yhä märehti Gubblumin


huomautusta mustasta silmästä.

"Hän on hapan kuin etikkasieni", ajatteli Gubblum.

Kuului askeleita yläpuolelta.

"Kukas nukkuu kyyhkyslakassa?" kysyi Gubblum ojentaen


sormensa ylöspäin.

"En tierä", kertasi Jabez.

"Hän on vihoissansa", ajatteli Gubblum.

*****

Juuri sillä hetkellä kapakan emäntä kapakkahuoneessa


askarrellessaan kuuli rattaitten pyörien ratinaa, ja seuraavana
hetkenä vaunut pysähtyivät ovelle.

"Kuulkaa, tulkaa auttamaan pian", huusi ajuri.

Rouva Drayton lenksutti ulos. Ajuri oli juuri kumartunut vaunun


ovesta sisään ja koetti auttaa ulos jotakin.
"Ottakaa kärestä, neiti; kas niin, se on oikea tapa."

"Varovasti nyt, herra, alas."

Autettava henkilö oli mies. Kapakkahuoneesta lankesi valo suoraan


hänen kasvoihinsa, ja kapakan emäntä näki hänet selvään. Se oli
Paul Ritson. Hän oli tuohtuneen näköinen ja hänen silmänsä
verestivät. Hänen takanansa oli Mercy Fisher kasvoillansa vielä
kyynelten jäljet.

"Oi, hän voi pahoin, rouva Drayton", sanoi Mercy.

Paul vapautti tytön syleilystä toisen kätensä, heilautti sitä


rauhoittavasti, hymyili heikosti ja sanoi:

"Ei, ei, ei — antakaa minun kävellä. Minä voin, hyvin, minä voin
hyvin."

Näin sanoen hän kääntyi taloon, mutta tuskin oli ottanut pari
askelta kun horjahti taaskin ja vaipui portaille.

"Herra varjelkoon, Herra varjelkoon, herraparkahan on aivan


voimaton", maurusi rouva Drayton hätäillen.

Paul Ritson naurahti vähän, kohotti punaiset silmänsä ja sanoi:

"Jaa, jaa! Ei se ole mitään. Päätä huimaa, siinä kaikki. Ja janottaa


— hirveästi. Antakaa minulle juotavaa, hyvä eukko."

"Tyhjentäkää tuo penkki, neiti, ja me asetamme hänet siihen


pitkälleen", sanoi ajuri. "Hyvä. Siinä voi levätä. Laskeutukaa siihen,
herra."
"Varjelkoon, varjelkoon, juokaa tämä, herra. Se tekee teille hyvin
hyvää. Se on viinaa."

"Vettä — antakaa minulle vettä", sanoi Paul heikosti. "Minä


näännyn janoon."

"Voi kauheata, kuinka kuuma hänen otsansa on!" huokasi Mercy.

"Eikä mitään keinoa viillyttää sitä", sanoi ajuri. "Asuuko hän täällä,
rouva?"

Rouva Drayton toi lasin vettä. Paul tyhjensi sen viime tippaan.

"Ei, herra; tuota, tarkoitan kyllä, ajuri", sanoi kapakan emäntä


hämmentyneenä.

"Hän ei ollut noin huono rattaille noustessaan", huomautti ajuri.

"Oi, rakas, rakas, missä on kirkkoherra Christian?" hätäili Mercy, ja


hänen silmänsä kiersivät ympäri huonetta.

"Herra kyllä tulee; hän on yläkerrassa, herra", selitti kapakan


emäntä ja itsekseen jotakin mutisten läpsytti tiehensä.

Paul Ritsonin pää oli painunut rinnalle. Hänen hattunsa oli poissa
ja hiukset valuivat silmille: Vahva mies istui kokoonlyyhistyneenä
penkillä. Hän koetti kohentaa itseänsä ja pudistaa päältään tämän
kauhean voimattomuuden, joka oli hänet vallannut.

"Oh, oh, kuka olisi luullut? Vettä — lisää vettä", hän pyysi heikolla
äänellä.

Mercy seisoi hänen edessään vesilasi kädessä.


"Onkohan se hyvä hänelle, epäilen?" hän sanoi. "Oi, missä on
kirkkoherra Christian?"

Paul Ritson huomasi lasin ja sieppasi sen molemmin käsin. Sitten


hän hymyili heikosti aivan kuin pyytäen anteeksi rajuuttansa ja joi
sen viimeiseen pisaraan.

"Oh, hoh — niin kuumaa ja pyörryttävää — ja kylmää", hän mutisi


sekavasti.

Sitten hän vaipui äänettömyyteen. Hetkisen kuluttua ajuri, joka oli


tukenut häntä, katsoi hänen kasvoihinsa. Silmät olivat suljetut ja
huulet riippuivat velttoina.

"Hän on menettänyt tajuntansa", sanoi ajuri. "Eikö teillä ole


minkäänlaista vuodetta?"

Silloin lynkytti rouva Drayton kiireesti alas aivan kuohuksissaan.

"Teidän pitäisi auttaa häntä ylös hänen huoneeseensa", hän sanoi


läähättäen henkeään vetäen.

"Siihen tarvitaan kaksi miestä, vai mitä luulette, rouva?" sanoi


ajuri.

Mercy oli avannut Paulin kauluksen ja vapisevin sormin hän koetti


viillyttää hänen palavaa otsaansa.

"Oh, sanokaa herra Christianille", hän pyysi, "sanokaa, että hän on


pyörtynyt."

Rouva Drayton riensi takaisin. Seuraavana hetkenä kuuluivat


miehen askelet laskeutuvan portaita. Hugh Ritson ilmestyi
kapakkahuoneeseen. Hän katsoi pyörtyneeseen mieheen ja koetti
hänen valtimoansa. "Koska tämä tapahtui?" hän kysyi Mercyyn
kääntyen.

"Hänen nuori vaimonsa, vai mitä?" kysyi ajuri Hughilta hieman


syrjässä.

Hugh nyökkäsi hieman päätänsä ja sanoi rouva Draytonille


merkitsevästi silmää iskien: "Teidän poikaparkanne näyttää olevan
kovin kipeä."

Kapakan emäntä katsahti vastaan hämmästynein ilmein ja melkein


änkyttäen selitti: "Herraparka —"

"Tämän vanhan vaimon poika?" kysyi ajuri osoittaen sormellansa


kapakan emäntää.

"Paul Drayton", sanoi Hugh.

Mercy näki ja kuuli kaiken. Kyyneleet hänen silmissään kuivuivat


äkkiä ja luomet jäivät hämmästyksestä selälleen. Hän ei puhunut
mitään.

Hugh huomasi tämän ilmeen muutoksen.

"Rouva Drayton", hän sanoi, "ettekö te sanonut, että teillä oli


Mercylle jotakin tärkeää tehtävää? Antakaa hänen suorittaa se heti
paikalla. — Nyt, ajuri, auttakaa minua. Ylös. Sinne on vain yksi
porras."

He nostivat Paul Ritsonin käsillensä ja lähtivät kantamaan häntä


kapakkahuoneesta.
"Missä juoksupoika on?" kysyi Hugh. "Älkää antako hänen tulla
tielle.
Pojista on enemmän vastusta kuin hyötyä", hän lisäsi selittäen.

He olivat saapuneet portaan juurelle. "Nyt, ukkoseni, tanakasti.


Raskas, vai? — aikalailla."

He kiipesivät ylös. Mercy seisoi keskellä lattiaa kyynelettömin


silmin ja valkein kasvoin.

Puolen minuutin kuluttua Hugh Ritson ja ajuri olivat palanneet


kapakkahuoneeseen. Merkillinen hymy leikki ajurin huulilla. Hugh
Ritsonin kasvot olivat tuhkanharmaat ja hänen huulensa vapisivat.

Matkatavarat, jotka Greta ja Paul olivat jättäneet


kapakkahuoneeseen kolme päivää sitten, olivat vielä nurkassa. Hugh
osoitti niitä ajurille. "Ottakaa nuo kärryihinne", hän sanoi. Ajuri alkoi
tehdä, kuten käskettiin.

Kun mies pääsi ovesta ulos, Hugh Ritson kääntyi rouva Draytoniin.
Kapakan emäntä löntysti ympäri huonetta hypistellen hermostuneesti
esiliinaansa. "Rouva Drayton", sanoi Hugh, "teidän on mentävä
ajurin kanssa pyhän Margaretin Westminsterin luostariin. Siellä
teidän on kysyttävä rouva Ritsonia, sitä rouvaa, joka jätti nuo tavarat
tänne perjantai-iltana. Teidän tulee sanoa hänelle, että teillä on
hänen tavaransa mukananne ja että hänen tulee seurata teitä St.
Pancraksen asemalle, jossa hän kohtaa miehensä ja sieltä he
matkustavat takaisin Cumberlandiin yöjunalla. Ymmärrättekö?"

"En voi sanoa, herra, ymmärränkö oikein, pyydän anteeksi, herra.


Jos nyt sattuisi niin, että rouva kysyisi, miksi hänen miehensä ei ole
tullut häntä hakemaan, entäpäs sitten?"
"Sanokaa sitten, mikä on totta — ei mitään muuta, rouva
Drayton."

"Ja mitä se sitten on, herra?"

"Että hänen miehensä on sairas. Mutta muistakaa: ei vaarallisesti."

"Oh! Sen minä voin kyllä sanoa nähtyäni, että se herraparka oli
aivan tajuton."

Rouva Drayton sitoi hatun päähänsä ja kääri shaalin ympärilleen.


Ajuri oli pannut tavarat vaunujensa pohjalle ja seisoi nyt
kapakkahuoneessa piiska kädessä.

"Ajurille ryyppy", sanoi Hugh. Rouva Drayton lähti pöytänsä taa.


"Ei, rientäkää rattaille, rouva Drayton. Mercy voi kyllä tarjota."

Mercy meni myymäpöydän taa ja tarjosi likööriä ajatellen aivan


muuta.

"Kello on nyt kymmenen ja kolmekymmentä", sanoi Hugh katsoen


kelloansa.
"Teidän tulee ajaa ensin Westminsterin luostariin ja sieltä St.
Pancraksen asemalle kahdentoista junalle."

Tämän sanottuaan hän astui ulos, avasi vaunun akkunan ja


kuiskasi: "Rouva Drayton, te ette saa puhua sanaakaan pojastanne,
kun keskustelette rouvan kanssa. Muistakaa se, ymmärrättekö."

Rouva Drayton asettautui mukavasti paikoilleen. "Kyllä, herra,


enhän tiedä, kun minä näin sen herran. Missä on Paul?"

"Vait!"
Ajuri tuli ulos. Hän hyppäsi istuimelleen. Seuraavana hetkenä
vaunut jyrisivät tiehensä.

Hugh Ritson palasi sisään. Jabez oli tullut alas. "Mihin aikaan te
suljette kapakan?" kysyi Hugh.

"Kello yksitoista, herra", vastasi Jabez.

"Täällä ei ole ketään. Te melkein yhtä hyvin voisitte sulkea sen nyt
heti paikalla. Ei väliä. Mene nukkumaan, poikaseni. Mercy, sinun
silmäsi ovat punaisemmat kuin koskaan ennen. Mene sinäkin
vuoteeseen arvelematta."

Mercyn silmät eivät olleet punaisemmat kuin niiden ilme oli


hämmästynyt. Hän liikkui konemaisesti. Kun hän joutui portaan
juurelle, hän kääntyi ja koetti puhua. Sanat eivät tahtoneet lähteä
hänen huuliltaan. Lopuksi hän sai omituisella äänellä sanotuksi:
"Sinä et puhunut minulle totta."

"Mercy!"

"Missä on kirkkoherra Christian?" kysyi Mercy, ja hänen äänensä


kävi lujemmaksi.

"Sinä et saa käyttää tuota ääntä minulle. Tule, käy vuoteeseen,


sinä pikku olento."

Mercyn silmät painuivat alas Hughin edessä. Hän kääntyi pois.


Hugh katsoi häntä, kunnes hän pääsi portaitten päähän. Niin varma
oli Hugh voimastaan, ettei edes tällaisena hetkenä epäillyt kykyänsä
hallita häntä.
Mutta Mercy ei mennyt vuoteeseen. Hän pistäysi avoimesta ovesta
Draytonin huoneeseen. Huone oli pimeä; vain kuu loi kalpeita
säteitänsä
poikki lattian. Mutta hän saattoi kuitenkin nähdä tunnottoman Paul
Ritsonin makaavan suorana vuoteella.

"Ja minä olen johtanut sinut tänne valheella", hän ajatteli. Hänen
päätänsä pyörrytti ja hän nojasi sitä vuoteen päähän. Muutamia
minuutteja kului äänettömyydessä. Hän kuuli askeleita ulkopuolelta.
Ne lähenivät tätä huonetta. Selällään oleva ovi liikahti. Kun Mercyllä
ei ollut aikaa paeta, hän painautui pimeässä piiloon sängyn ja seinän
väliin.

Kaksi miestä astui huoneeseen. Mercy tajusi heidän läsnä-olonsa


pimeässä enemmän tuntoaistillansa kuin korvillansa ja silmillänsä. He
astuivat varovasti. Pimeys peitti heidät, mutta ilmassa tuntui heidän
kuuma hengityksensä. Toinen heistä lähestyi vuodetta. Mercy tunsi
vuoteen heiluvan. Mies kumartui sen yli, ja seurasi täydellinen
hiljaisuus. Vain tunnottoman miehen tuskin kuuluva hengitys häiritsi
sitä.

"Hän on kyllin vaaraton vielä", sanoi ääni, joka viilteli Mercyn koko
olentoa kuin tulinen miekka. "Nyt asiaan, ei ole hetkeäkään hukata."

Tyttö lyyhistyi yhä enemmän kokoon ja pidätti hengitystänsä.

"Saatana, ellen minä mielelläni tahtoisi päästä koko hommasta",


mutisi toinen ääni.

Mercy tunsi molemmat miehet. Ne olivat Hugh Ritson ja Paul


Drayton.
Hugh sulki oven. "Mitä tomppelit pitävät onnena, sen viisas ottaa
omin käsin", hän sanoi matalalla, ivallisella äänellä. "Tässä jalkainne
juuressa on onni, joka on teidänlaisellenne miehelle kyllin sopiva."

Drayton mutisi, ja Mercy kuuli toisen kirouksen tulevan hänen


hampaittensa välistä. "Minä haluan vapautua tästä enkä häpeä
ilmoittaa sitä teille."

Hugh Ritsonin kevyt naurahdus kuului vuoteena luota. Hän seisoi


yhä Paul Ritsonin päänpohjissa. "Jos Isä Jumala tulisi teitä
hakemaan tulisilla vaunuilla ja salamat suojanansa, ette jättäisi
turvallisemmin tätä taloa kuin tämän työn tehtyänne", hän sanoi.
"Tulkaa ja säästäkää sanoja. Riisukaa pois tuo paljonpuhuva takki."

Sitten hän kumartui vuoteen yli, ja kuului vieteripatjan natinaa.

"Mitä tuo on?" kysyi Drayton hätääntyneellä äänellä.

"Jumalan tähden, olkaa mies", sähähti Hugh Ritson katkerasti.

"Sanotteko te tätä miehen työksi?" mutisi Drayton.

Hiljainen nauru kuului uudestaan. "Ehk'ei se ole niin miehekästä


kuin ruumiiden ja kuolevien ryöstäminen", sanoi Hugh Ritson, ja
hänen äänensä oli kylmä ja kova.

Mercy kuuli toisen mutistun kirouksen. Taivaan herra! Mitä nyt oli
tekeillä? Voisiko hän paeta? Ovi oli lukossa. Jos hän voisi päästä
sinne, hän voisi avata sen ja paeta.

Aivan kuin vastaukseksi hänen ajatuksillensa Hugh Ritson sanoi


"odottakaa", ja astui ovelle asettaen salvankin paikoilleen. Mercy
nojasi seinään ja kuuli sydämensä sykinnän. Pimeässäkin hän tunsi,
että Paul Drayton oli vetänyt takkinsa päältään. "Hyvä pelastus!"
Drayton mutisi ja raskas vaate putosi muksahtaen lattialle.

Hugh Ritson oli palannut vuoteen pääpuoleen. "Auttakaa minua",


hän sanoi. "Nostakaa häntä varovasti. Kas niin, minä pidän häntä
ylhäällä. Vetäkää nyt pois hänen takkinsa — hiljaa, yksi hiha
kerrassaan. Onko se irti? Vetäkää se sitten pois."

Toinen raskas vaate muksahti maahan.

"Mitä poika on saanut toiseen taskuunsa, häh?"

"Tulkaa, auttakaa vielä. Riisukaa pois kengät — ne ovat


cumberlandilaista tekoa ja teidän on lontoolaista tyyliä — pian."

Drayton astui vuoteen jalkopäähän ja näpelöitsi tajuttoman


miehen jalkoja. Hän oli silloin vain kyynärän päässä tytön
piilopaikasta. Mercy tunsi hänen läheisyytensä ja alkoholin tuoksu
tunkeutui hänen sieraimiinsa. Hän oli puolipyörryksissä ja pelkäsi
kaatuvansa. Hän ojensi toisen kätensä tukeaksensa itseänsä ja se
sattui sängynlaitaan tuskin jalan päähän Draytonin kädestä.

"Ottakaa pois sukat — ne ovat kotikutoiset minä päästän irti


kravatin. Neula oli lahja hänellä ja sen takapuolelle on kaiverrettu
hänen nimensä."

Kuun valojuova oli kadonnut lattialta ja kaikki oli pimeää.

Drayton näytti pääsevän vauhkosta pelostaan. Hän nauroi ja


pöyhisteli. "Miten hiljaa tuo sankari on! Ihan kuin olisi mielissään!
Totisesti — hän pyörtyi ihan sopivaan aikaan. Kauankohan tuo
kestää?"
"Pian riisukaa päältänne ja pukekaa ne noiden sijaan. Missä on
päällystakki, jonka lieve on revennyt? Älkää erehtykö siinä."

"Siitä panen pääni pantiksi", sanoi Drayton raa'asti naurahtaen.

Pimeässä oli kuuluvinaan jotakin liikettä.

"Hyst!"

Mercy tiesi, että Hugh Ritson oli tarttunut Draytonin käteen ja


molemmat kuuntelivat henkeä pidättäen. Tällä hetkellä kuu pilkisti
sisään ja kalpea juova, joka oli langennut poikki lattian, ulottui nyt yli
sängyn. Se valaisi ryöstetyn miehen kasvoja. Hänen silmänsä olivat
auki.

"Vettä, vettä", pyysi Paul Ritson hyvin heikosti.

Hugh Ritson astui kuun valosta pimeään veljensä selkäpuolelle, ja


Mercy näki käden pitävän viinapulloa Paulin suun edessä.

Kun käsi kohotettiin, kasvot nytkähtivät heikosti, silmäluomet


räpähtelivät suonenvedontapaisesti ja kohotettu pää retkahti
hervottomana tyynylle.

"Hän on äänettömämpi nyt kuin koskaan", sanoi Hugh Ritson


tyytyväisenä. Mercy tunsi tarvetta parahtaa, mutta itsesäilytysvaisto
piti häntä hiljaa. Hän ei liikauttanut jäsentäkään. Hänen päänsä
nojasi seinään, silmät tuijottivat pimeään, jano poltti hänen kieltänsä
ja avautuneet huulet olivat hehkuvan kuumat.

"Pian! Pankaa nämä vaatteet päällenne ja suorikaamme heti


tiehemme!"
Drayton puki vaatteet päällensä ja nauroi käheästi.

"Ja niin sopivat — ihan kuin tehdyt — saatana!" hän sanoi lausuen
d:n ihan oikein, vaikka se tavallisesti oli r.

Ovi ja akkuna olivat vastakkain. Vuode oli ovesta vasemmalle pää


oveen päin. Ahdas paikka, jossa tyttö piili, oli vasemmalle akkunasta
ja akkunan edessä oli pukeutumispöytä. Drayton astui sen ääreen
järjestääkseen kravattinsa peilin edessä. Heikko kuun valo lankesi
hänen kasvoillensa ja hän näki petomaisen ilmeensä peilistä.

Tänä hetkenä Mercyn kipeät silmät kääntyivät vuoteeseen.


Hievahtamatta kuin kuollut lepäsi siinä Paul Ritson kasvot
käännettyinä ylöspäin. Luonto oli valanut kahdet kasvot samaan
muottiin — toiset olivat valkeat, ylevät ja rauhalliset, toiset taas
pöhöttyneet, punaiset ja riettaat, joihin intohimot olivat painaneet
lähtemättömän häpeämerkin.

"Ihan sama — ihan sama! Saatana, voisiko hänen oma äitinsä


erottaa minua omasta pojastaan."

Hugh Ritson astui Draytonin rinnalle. Kun hän puhui, oli hänen
äänensä kylmä kuin jäätävä viima.

"Kuule nyt. Tästä hetkestä, jolloin sinä muutat pukua, sinä lakkaat
olemasta Paul Drayton ja muutut Paul Ritsoniksi."

"Etkös sinä sanonut, että minusta tulee Paul Lowther?"

"Se tapahtuu myöhemmin."

"Johan ininä sanoin, ettei tämä mahdu minun kallooni."


"Ei väliä. Älä puhu itsellesi mitään muuta kuin 'Minun tulee olla
olevinani Paul Ritson!'"

"No, se kyllä käy."

"Valmis?" kysyi Hugh. Hän kääntyi vuoteeseen

"Valmis."

"Auta sitten minua. Meidän täytyy viedä hänen sinun ullakollesi.


Kun poliisi tulee häntä ottamaan, hänen täytyy näyttää juopuneena
piileskelevän. Ymmärrätkö?"

Hiljainen, käheä nauru oli ainoa vastaus.

Sitten he nostivat tunnottoman miehen vuoteesta avasivat oven ja


kantoivat hänet käytävään.

*****

Mercy heräsi lamaannuksestaan kuin unesta. Kun miehet olivat


menneet, hän hiipi varpaisillaan käytävään ja omaan huoneeseensa.
Ovella hän pyörtyi ja kaatui raskaasti maahan. Välillä tajunta palasi
ja hän kuuli sanat: "Kanna hänet takaisin omaan huoneeseensa ja
lukitse ovi." Samana hetkenä hän tunsi voimakkaiden käsien
tarttuvan häneen ja kantavan hänet pois.
XVI LUKU.

Ennenkuin Gubblum Oglethorpe erosi Jabezista, hän koetti hyvittää


sen pahan mielen, jonka oli hänelle tuottanut. "Anna minulle kätesi
ja sovitaan pois", hän sanoi ojentaen kätensä. Mutta Jabez ei ollut
unohtanut, mitä Gubblum oli hänelle mustasta silmästä sanonut. Hän
ei vastannut mitään.

"Hänet saa hulluna hirttää", ajatteli Gubblum. "Hän on kenkku


kuin löntyskä." Sitten Gubblum muisti, millä keinoin hän oli koettanut
saada pojan reilummaksi, kuitenkaan onnistumatta. "Hän vei mun
shillingini kuin kelpo koijari", hän ajatteli. "Sietäisi tuommoinen
tolvana leipoa uudestaan."

Jabez pani kynttilän kädestään ja vetäytyi huoneesta katsoen


toiseen kuin kummitukseen.

"Ei sun tartte pelätä mua. En mää aio sull' pahaa tehrä", sanoi
Gubblum leveimmällä murteellansa. Jabez työnsi oven auki. "Hänen
päänsä on pudingista ja pannurieskasta", ajatteli Gubblum.

Sitten kerjäläinen istui vuoteen reunalle ja ajatteli, mitä järjellistä


syytä pojalla oli muuttua tuollaiselle tuulelle. Hän istui kauan, ja
monia teräviä ajatuksia kulki hänen aivojensa läpi. Lopuksi hän
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like