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

iOS 12 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 5th Edition Matt Neuburg pdf download

The document is a comprehensive guide to iOS 12 programming fundamentals using Swift, Xcode, and Cocoa, authored by Matt Neuburg. It covers various topics including Swift language architecture, functions, variables, object types, and flow control, as well as practical aspects of using Xcode for app development. The fifth edition was published by O'Reilly Media in September 2018 and includes detailed explanations and examples for learners and developers.

Uploaded by

robesrbalowbb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
7 views

iOS 12 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 5th Edition Matt Neuburg pdf download

The document is a comprehensive guide to iOS 12 programming fundamentals using Swift, Xcode, and Cocoa, authored by Matt Neuburg. It covers various topics including Swift language architecture, functions, variables, object types, and flow control, as well as practical aspects of using Xcode for app development. The fifth edition was published by O'Reilly Media in September 2018 and includes detailed explanations and examples for learners and developers.

Uploaded by

robesrbalowbb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

iOS 12 Programming Fundamentals with Swift Swift

Xcode and Cocoa Basics 5th Edition Matt Neuburg


download

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

Download more 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-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 10 Programming Fundamentals with Swift Swift Xcode


and Cocoa Basics 3rd Edition Matt Neuburg

https://textbookfull.com/product/ios-10-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-3rd-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 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 12 Dive Deep Into Views View


Controllers and Frameworks 1st Edition Matt Neuburg

https://textbookfull.com/product/programming-ios-12-dive-deep-
into-views-view-controllers-and-frameworks-1st-edition-matt-
neuburg/
Xc

C o 0,
od

ve a n
e1

rs d
i O Sw
S 1 if t
2, 4
.2
iOS 12
Programming
Fundamentals
with Swift
SWIFT, XCODE, AND COCOA BASICS

Matt Neuburg
FIFTH EDITION

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

Matt Neuburg

Boston
iOS 12 Programming Fundamentals with Swift, Fifth Edition
by Matt Neuburg
Copyright © 2018 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://oreilly.com/safari). For more information, contact our corporate/insti‐
tutional sales department: 800-998-9938 or corporate@oreilly.com.

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
October 2017: Fourth Edition
September 2018: Fifth Edition

Revision History for the Fifth Edition


2018-09-26: First release

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

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. iOS 12 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-492-04455-0
[LSI]
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

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 13
Namespaces 13
Modules 14
Instances 15
Why Instances? 17
The Keyword self 19
Privacy 20
Design 22
Object Types and APIs 23
Instance Creation, Scope, and Lifetime 25
Summary and Conclusion 25

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

iii
Overloading 34
Default Parameter Values 35
Variadic Parameters 35
Ignored Parameters 36
Modifiable Parameters 37
Function in Function 40
Recursion 42
Function As Value 42
Anonymous Functions 45
Define-and-Call 51
Closures 52
How Closures Improve Code 54
Function Returning Function 55
Closure Setting a Captured Variable 58
Closure Preserving Its Captured Environment 59
Escaping Closures 60
Curried Functions 60
Function References and Selectors 62
Function Reference Scope 64
Selectors 65

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


Variable Scope and Lifetime 69
Variable Declaration 71
Computed Initializer 74
Computed Variables 76
Setter Observers 79
Lazy Initialization 80
Built-In Simple Types 82
Bool 82
Numbers 84
String 92
Character and String Index 96
Range 101
Tuple 103
Optional 105

4. Object Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119


Object Type Declarations and Features 119
Initializers 121
Properties 127
Methods 130

iv | Table of Contents
Subscripts 132
Nested Object Types 135
Instance References 135
Enums 137
Raw Values 138
Associated Values 140
Enum Case Iteration 142
Enum Initializers 143
Enum Properties 144
Enum Methods 145
Why Enums? 146
Structs 147
Struct Initializers, Properties, and Methods 147
Struct As Namespace 149
Classes 149
Value Types and Reference Types 150
Subclass and Superclass 156
Class Initializers 161
Class Deinitializer 169
Class Properties and Methods 170
Polymorphism 172
Casting 175
Casting Down 176
Type Testing and Casting Down Safely 176
Type Testing and Casting Optionals 178
Bridging to Objective-C 178
Type References 180
From Instance to Type 180
Type as Value 181
The Keyword Self 183
Comparing Types 184
Summary of Type Terminology 185
Protocols 186
Why Protocols? 187
Protocol Type Testing and Casting 189
Declaring a Protocol 190
Protocol Composition 191
Optional Protocol Members 192
Class Protocol 194
Implicitly Required Initializers 195
Literal Convertibles 196
Generics 197

Table of Contents | v
Generic Declarations 200
Contradictory Resolution 202
Type Constraints 203
Explicit Specialization 205
Generic Invariance 207
Associated Type Chains 208
Where Clauses 210
Extensions 213
Extending Object Types 213
Extending Protocols 215
Extending Generics 217
Umbrella Types 219
Any 219
AnyObject 221
AnyClass 223
Collection Types 224
Array 224
Dictionary 240
Set 247

5. Flow Control and More. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253


Flow Control 253
Branching 254
Loops 266
Jumping 271
Privacy 286
Private and Fileprivate 288
Public and Open 289
Privacy Rules 290
Introspection 290
Operators 291
Synthesized Protocol Implementations 295
Key Paths 298
Dynamic Member Lookup 300
Memory Management 301
Memory Management of Reference Types 301
Exclusive Access to Value Types 308

Part II. IDE

vi | Table of Contents
6. Anatomy of an Xcode Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
New Project 313
The Project Window 315
The Navigator Pane 317
The Utilities Pane 322
The Editor 323
The Project File and Its Dependents 325
What’s In the Project Folder 326
Groups 327
The Target 328
Build Phases 328
Build Settings 330
Configurations 331
Schemes and Destinations 333
From Project to Built App 335
Build Settings 338
Property List Settings 338
Nib Files 339
Additional Resources 340
Code Files 342
Frameworks and SDKs 343
The App Launch Process 345
The Entry Point 345
UIApplicationMain 346
App Without a Storyboard 348
Renaming Parts of a Project 349

7. Nib Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351


The Nib Editor Interface 352
Document Outline 353
Canvas 356
Inspectors and Libraries 358
Nib Loading 359
When Nibs Are Loaded 360
Manual Nib Loading 361
Connections 363
Outlets 363
The Nib Owner 364
Automatically Configured Nibs 368
Misconfigured Outlets 369
Deleting an Outlet 371
More Ways to Create Outlets 372

Table of Contents | vii


Outlet Collections 374
Action Connections 375
More Ways to Create Actions 377
Misconfigured Actions 379
Connections Between Nibs — Not! 379
Additional Configuration of Nib-Based Instances 380

8. Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
The Documentation Window 385
Class Documentation Pages 386
Quick Help 390
Symbol Declarations 392
Header Files 393
Sample Code 394
Internet Resources 394

9. Life Cycle of a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397


Environmental Dependencies 397
Permissible Runtime Environment 398
Backward Compatibility 398
Device Type 400
Arguments and Environment Variables 401
Conditional Compilation 402
Version Control 404
Editing and Navigating Your Code 407
Autocompletion 409
Snippets 410
Fix-it and Live Syntax Checking 412
Navigation 413
Finding 415
Refactoring 416
Running in the Simulator 416
Debugging 417
Caveman Debugging 417
The Xcode Debugger 420
Testing 427
Unit Tests 428
Interface Tests 431
Clean 433
Running on a Device 433
Obtaining a Developer Program Membership 434
Signing an App 435

viii | Table of Contents


Automatic Signing 436
Manual Signing 439
Running the App 441
Managing Development Certificates and Devices 442
Profiling 442
Gauges 442
Memory Debugging 444
Instruments 445
Localization 448
Distribution 453
Making an Archive 453
The Distribution Certificate 454
The Distribution Profile 456
Distribution for Testing 457
Final App Preparations 458
Screenshots and Video Previews 461
Property List Settings 463
Submission to the App Store 464

Part III. Cocoa


10. Cocoa Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Subclassing 469
Categories and Extensions 472
How Swift Uses Extensions 472
How You Use Extensions 473
How Cocoa Uses Categories 473
Protocols 475
Informal Protocols 477
Optional Methods 477
Some Foundation Classes 480
NSRange and NSNotFound 481
NSString and Friends 483
NSDate and Friends 486
NSNumber 487
NSValue 489
NSData 490
NSMeasurement and Friends 491
Equality, Hashability, and Comparison 491
NSArray and NSMutableArray 494
NSDictionary and NSMutableDictionary 496

Table of Contents | ix
NSSet and Friends 496
NSIndexSet 497
NSNull 498
Immutable and Mutable 498
Property Lists 500
Codable 501
Accessors, Properties, and Key–Value Coding 504
Swift Accessors 505
Key–Value Coding 507
Uses of Key–Value Coding 508
KVC and Outlets 510
Cocoa Key Paths 510
The Secret Life of NSObject 511

11. Cocoa Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513


Reasons for Events 513
Subclassing 514
Notifications 516
Receiving a Notification 517
Unregistering 519
Posting a Notification 520
Timer 521
Delegation 523
Cocoa Delegation 523
Implementing Delegation 525
Data Sources 527
Actions 527
The Responder Chain 530
Deferring Responsibility 531
Nil-Targeted Actions 532
Key–Value Observing 533
Registration and Notification 534
Unregistering 535
Key–Value Observing Example 536
Swamped by Events 537
Delayed Performance 540

12. Memory Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543


Principles of Cocoa Memory Management 543
Rules of Cocoa Memory Management 544
What ARC Is and What It Does 545
How Cocoa Objects Manage Memory 546

x | Table of Contents
Autorelease Pool 547
Memory Management of Instance Properties 549
Retain Cycles and Weak References 550
Unusual Memory Management Situations 552
Notification Observers 552
KVO Observers 554
Timers 554
Other Unusual Situations 556
Nib Loading and Memory Management 556
Memory Management of CFTypeRefs 557
Property Memory Management Policies 559
Debugging Memory Management Mistakes 561

13. Communication Between Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563


Visibility by Instantiation 564
Visibility by Relationship 566
Global Visibility 567
Notifications and Key–Value Observing 569
Model–View–Controller 569

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

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607

Table of Contents | xi
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 consider
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 Swift deserved to be, and probably would be, adopted by
new students of iOS programming, and that my books, therefore, should henceforth
assume that readers are using Swift.
That decision has proven prophetic. Programmers of iOS have flocked to Swift in
increasing numbers, and Swift itself has only improved. My iOS apps (such as Diabel‐
li’s Theme, LinkSame, Zotz!, TidBITS News, and my Latin and Greek flashcard apps)
have all been rewritten in Swift, and are far easier for me to understand and maintain
than their Objective-C originals.
Xcode 10 comes with Swift 4.2. The language has evolved greatly in its details and in
the nature of its integration with the Cocoa libraries that underlie iOS programming,
but its spirit has remained constant. 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.

xiii
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.
Memory management
Swift manages memory automatically. You will rarely have to concern yourself
with memory management.
Cocoa compatibility
The Cocoa APIs are written primarily 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.
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.
Still, the reader may 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 might have to know what those lan‐
guages would expect.

xiv | Preface
Therefore, although I do not attempt to teach Objective-C in this book, I do describe
it in enough detail to allow you to read it when you encounter it in the documenta‐
tion and on the Internet, and I occasionally show some Objective-C code. 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 commu‐
nicate 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 12, 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 12 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 12. Conversely, Programming iOS 12 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 12 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

Preface | xv
Swift playgrounds or the REPL. My focus here is real-life iOS programming, and
my explanation of Swift therefore concentrates on those common, practical
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 12, of course!

Versions
This book is geared to Swift 4.2, iOS 12, and Xcode 10.
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).

xvi | Preface
A word about method names. I generally give method names in Swift, in the style of a
function reference (as described in Chapter 2) — that is, the name plus parentheses
containing the parameter labels followed by colon. 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 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 10 under macOS 10.13 High Sierra. I
have not upgraded my machine to macOS 10.14 Mojave, 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 running Mojave, your interface may naturally look slightly different from
the screenshots (especially if you’re using “dark mode”), but this difference will be
minimal and shouldn’t cause any confusion.

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.
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)

Preface | xvii
• 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.
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.

xviii | Preface
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:
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.

Preface | xix
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 12 Programming Fundamentals
with Swift by Matt Neuburg (O’Reilly). Copyright 2018 Matt Neuburg,
978-1-492-04455-0.”
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at permissions@oreilly.com.

Safari® Books Online


Safari (formerly Safari Books Online) is a membership-
based training and reference platform for enterprise, gov‐
ernment, educators, and individuals.
Members have access to thousands of books, training videos, Learning Paths, interac‐
tive tutorials, and curated playlists from over 250 publishers, including O’Reilly
Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Profes‐
sional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press,
John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe
Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and
Course Technology, among others.

xx | Preface
For more information, please visit http://oreilly.com/safari.

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/ios12-prog-fundamentals.
To comment or ask technical questions about this book, send email to bookques‐
tions@oreilly.com.
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
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Preface | xxi
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
programming.
• 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 describe Swift access
control (privacy), introspection (reflection), and how to create your own opera‐
tors. There follows a discussion of some recently added Swift language features:
synthesized protocol implementations, key paths, and dynamic member lookup.
The chapter concludes by considering Swift 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
semicolon 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 runs.
The Swift compiler’s error and warning messages, however, 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 occa‐
sional 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
Other documents randomly have
different content
The Project Gutenberg eBook of Atchoo! Sneezes from a Hilarious
Vaudevillian
This ebook is for the use of anyone anywhere in the United States and most other parts of the
world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use
it under the terms of the Project Gutenberg License included with this ebook or online at
www.gutenberg.org. If you are not located in the United States, you will have to check the laws of
the country where you are located before using this eBook.

Title: Atchoo! Sneezes from a Hilarious Vaudevillian

Author: George Niblo

Release date: February 18, 2013 [eBook #42122]


Most recently updated: October 23, 2024

Language: English

Credits: E-text prepared by Demian Katz and the Online Distributed Proofreading Team
(http://www.pgdp.net) from page images generously made available by Villanova
University Digital Library (http://digital.library.villanova.edu/)

*** START OF THE PROJECT GUTENBERG EBOOK ATCHOO! SNEEZES FROM A HILARIOUS
VAUDEVILLIAN ***
The Project Gutenberg eBook, Atchoo!, by George Niblo

Note: Images of the original pages are available through Villanova University Digital Library. See
http://digital.library.villanova.edu/Americana/Dime%20Novel/Street%20and%20Smith/StreetandS
07242dbb-24fe-42df-98f4-2b994c86e60a.xml

Click on illustrations to view larger versions.

S. & S. HUMOR LIBRARY No. 2—ILLUSTRATED—PRICE, 25 CENTS

"ATCHOO!"
Sneezes from a Hilarious Vaudevillian
BY

GEORGE NIBLO
STREET & SMITH - PUBLISHERS - NEW YORK
ATCHOO!
Sneezes from a Hilarious Vaudevillian

BY
GEORGE NIBLO

NEW YORK
STREET & SMITH, Publishers
238 William Street

Copyright, 1903

By STREET & SMITH

Atchoo!
ATCHOO!

Fellow citizens!—I beg pardon, I mean ladies and gentlemen! You see I've just
come from a political meeting, and that sort of thing gets on your nerves. I went
to hear my friend Isaacstein talk. His subject was "Why should the Jew have to
work?"
They did a lot of whitewashing at that meeting. I suppose it's all right. Of course
you can't make a new fence with a pail of whitewash, but you can cover up the
mothholes.
But we mustn't be too hard on the politicians. If it wasn't for politics a good many
fellows that are too lazy to earn a living with their hands would be paupers. But
some of 'em are all right. There's Isaacstein for instance. As good a man as ever
sauntered down Hester Street. He joined the noble army of grafters two years ago
and worked so hard at his profession that he got appendicitis.
A friend of Isaacstein's met another acquaintance of his in Hester Street and
asked:
"Haf you heard aboudt Isaacstein?"
"No. Vat iss it?"
"He vas sick. They take him by der hospital, and vat you tink they do to him?"
"Vell. Vell. Vat iss it?"
"They put him in a room all by himself und take his appendix away from him."
"Na! Na! Na! Vat a pity, ain't it, he didn't have it in his wife's name?"
Why, I was taken sick myself lately—such thing will happen even in the best
regulated families, you know.

The doctor came and said that he


Would make another man of me.
"All right," said I, "and if you will,
Just send that other man your bill."

While I was on my way here there was a fire down in one of those thickly populated streets where
twenty families and more live, like sardines, in a tenement. The fire engine came booming along, and as
usual created tremendous excitement.
I noticed a small chap on a bicycle riding zigzag in front of the machine, evidently anxious to keep up
with it and get to the fire in time to watch it begin work.
Half a dozen times the driver had to pull up suddenly to avoid running over the nervy little Hebrew, and
this of course made the firemen riding with the machine furious.
Just in front of where I was standing one of the gallant life savers jumped down from the engine,
caught hold of the boy and pulled him off to one side, at the same time saying:
"You miserable little Sheeney, you ought to be arrested for getting in the way! I've a good mind to
spank you."
The boy looked at the fireman in surprise and whimpered:
"If it wasn't for the Jews you wouldn't have anything to do."
I often squander an hour or two down in Hester
Street, where I have some rare acquaintances among
the second-hand dealers.
Of course you understand that I only go there to
study human nature, and I remember some months
ago being delightfully entertained at a Jewish
wedding, where my esteemed friend Moses
Schaumburg gave his cherished Rebecca into the
keeping of young Silverstein, a progressive Broadway
salesman.
This fact was brought to my mind when, only the
other day I saw the bridegroom rush into his father-
in-law's establishment bearing a look of excitement, and also a few very positive scratches upon his
olive face, and exclaiming dramatically:
"Mister Schaumburg, I vants you to dake back your daughter Rebecca."
The old man threw up his hands.
"I dakes not dot Repecca back. Ven a man comes to my house, picks out
himself a piece of goots, and dot goots vas received by him in goot order, I
vould be a fool to dake pack dot goods. No, sir, you schoost keep dot
Repecca."
My brother Tom was hit on the head some time ago,
and at the hospital they said they would have to
amputate half his brain. I didn't want them to,
because he is absent-minded anyway.
"We'll have to give him something to make him sleep,"
said one of the surgeons.
"That won't be necessary," said another; "he's a policeman."
That made Tom sore, and he snapped: "I've got half a mind to cave in your
ribs for you."
"You won't feel that way in a minute," said the surgeon, "because that's the
half of your mind we're going to cut out."
It was a great operation. When I told my wife of the surgeon's little joke and
how Tom came back at him she said she never knew a time when Tom wasn't
ready to give anybody a piece of his mind.
Tom was a confirmed dyspeptic, too, and when the operator was taking an X-ray photograph of the seat
of his troubles, this waggish brother of mine, with a ghastly attempt to be facetious, said:
"This, I suppose, is what might be called taking light exercise on an empty stomach."
Perhaps it may surprise you to hear me say that some years ago I was
connected with the newspaper business.
I don't tell this to everybody, you know, but there are some little things
connected with my experience that drive away the blues in these times when
the ghost refuses to walk regularly on pay day.
It was out in old Kaintuck, the Blue Grass country famous for its fast horses,
fair women and old Bourbon.
Say, have you ever been in the land of Daniel Boone and Davy Crockett, the
original Tennessee Congressmen?
You don't know what you've missed then—grand scenery, splendid cooking, and the most original
people in the mountains, where they make that moonshine whiskey you've heard about.
I used to hustle right lively looking for news, and during the course of my
journeyings I ran across a grizzled old farmer from the back settlements, who
looked like he might be a good judge of double distilled mountain dew that had
paid no revenue to Uncle Sam.
Of course I tackled him right away, and first lining him up in the tap-room of
the tavern, asked what news there might be up in his section, for it was a
warm corner of the State, and could usually be depended on for some lively
incidents during the week.
His answer rather disappointed me at first.
"They ain't nothin' doin' up our way," he said, "'cause we're all too busy with
our crops to bother about anything else. All quiet in our neighborhood for
sartin."
"Pretty good crops this year?" I inquired.
"Bully," says he. "I ought to be in my field this minute, an' I would be if I hadn't come to town to see
the coroner."
"The coroner?" I began to feel interested, because you know there's only one kind of harvest that needs
a coroner.
"Yep. Want him to hold an inquest on a couple of fellers down in our neighborhood."
"Inquest? Was it an accident?"
"Nope. Zeke Burke did it a-puppus. Plugged George Rambo and his boy Bill
with a pistol. Got to have an inquest."
"What caused the fight?"
"There wasn't no fight. Zeke never give the other fellers a show. Guess he was
right, too, 'cause the Rambos didn't give Zeke's father an' brother any chance.
Just hid behind a tree and fired at 'em as they came along the road. That was
yistiday mornin', an' in an hour Zeke had squared accounts."
"Has Zeke been arrested?"
"Nope. What's the use? Some of old man Rambo's relatives came along last
night, burned down Zeke's house, shot him an' his wife, an' set fire to his barn.
Nope, Zeke hasn't been arrested. But I ain't got time to talk to you. Have to git
back to my harvestin'. But there ain't no news down our way. If anythin'
happens I'll let ye know."
One of my best friends down there was an old judge who knew more about whiskey than he did about
law. One day a young lawyer came to town and hung up his shingle.
Up to that day the judge had been the only member of the legal fraternity there.
Old Si Corntassle, a close-fisted farmer, sizing up the situation, thought it a good chance to corner some
legal advice without cost, so he hastened to call upon the young man, told him he was very glad he had
come into the town, as the old judge was getting superannuated, and then contrived in a sort of
neighborly talk to get some legal questions answered.
Then thanking the young sprig of the bar, he put on his hat and was about to leave, when the lawyer
asked him if he should charge the advice, for which the fee was five dollars.
The old fellow went into a violent passion and swore he never would pay, but the young lawyer told him
he would sue him if he didn't.
So old Si trotted down to see the
judge, found him hoeing in his
garden, and said:
"That young scamp that's just
come into town! I dropped in to
make a neighborly call on him and
he charged me five dollars for legal
advice."
"Served you right," said the judge,
who sized up the situation, and
saw a chance to pay off an old
score; "you had no business to have gone to him."
"But have I got to pay it, judge?"
"Of course you have."
"Well, then," said the man, "I suppose I must," and he started off.
"Hold on!" said the judge; "aren't you going to pay me?"
"Pay you? What for?" said old Si.
"For legal advice."
"What do you charge?"
"Ten dollars."
And consequently as old Si had to settle with both he rather overreached himself in the transaction.
Some of you people doubtless find benefit in visiting the country, but I imagine Snellbaker, who has a
gents' furnishing-goods emporium on the corner of a Brooklyn Street, rather carries off the prize in a
profitable trip.
I met him the other day, well sunburned, and with a twinkle in his eye.
"I say, Mr. Niblo, did you hear about my luck?" he asked, slapping me on the
shoulder.
"Why, no, what's happened now?" I replied, wondering if he had drawn the
grand prize in a lottery, or if his children had the measles.
"Well, you know when I went away to the country, I
only took my five children and I brought ten home with
me."
"How was that?" I asked, in surprise.
"Well, they ate green apples and got doubled up."
Singular what queer things do happen on the electric
cars of a great metropolis. The other day I was riding
down to the City Hall in a pretty crowded car when something happened.
All the other passengers in the car were men except one; and she was a girl, a
nice, pretty, young thing of that peculiar pinkish clarity of complexion more
commonly designated "peaches and cream."
The conductor had just collected her fare and was proceeding on his way to the rear platform when the
girl grabbed at the left arm of her jacket and emitted a gaspy little scream.
"What is it, miss?" asked the conductor.
"Oh, what shall I do?" moaned the girl. "I've lost it! I've lost my Yale pin!"
And she looked as if she would topple over on the man next to her. The
conductor stooped and looked about the floor of the car. All of us passengers
did the same. The pretty young thing shook out her skirts vigorously. All hands
lent their aid to lift up the gratings and to search the space beneath them.
There was, however, no signs of the cherished emblem. About the time
everybody was beginning to feel exhausted the girl suddenly exclaimed:
"Oh, I remember now! It's all right. Don't bother any more. I gave it back last
night."
"City Hall!" yelled the conductor, and I was glad to get off.
Last time I rode in a trolley car I got a scare for sure. Honestly now, it gave me
a queer feeling up and down my spine when I noticed that the car number was
1313, and what made it worse we were just passing Thirteenth Street at the
time.
I thought I would mention the fact to the conductor, especially when upon counting the passengers I
found there were just that fatal number aboard.
It was the thirteenth of the month too, and bless you if that conductor's number wasn't just 3913.
So I grimly paraded these significant facts before the attention of the knight of the fare register.
"I should think it would make you nervous!" I remarked.
"Only once't that I remember," said the conductor, with a grin.
"When and how?"
"There was thirteen babies in this here car yellin' in thirteen different keys all
at the same time," replied the conductor.
Some people are so superstitious, you know, always carrying home old
horseshoes and nailing them up over the door—why, a pagan nation like the
Japanese have the same custom with other embellishments.
The fun of it is, while some stoutly maintain the horseshoe must be nailed with
the forks pointing upward, there are others just as set in their belief that if a
chap wants real good luck to swoop down upon his domicile it is absolutely
imperative that the opening must be left below.
Why Ketcham actually grew hot under the collar the
other day because I sneered when he chanced to
mention what horrible bad fortune had come to him since his propitiation to
the gods was stolen from his barn door by a wandering dago junk-man.
"Don't you believe then that there's good luck in finding a horseshoe?" he
demanded, fiercely.
"Why, yes, under certain conditions," I replied; "for instance when you find it
on the winning horse."
Ketcham is quite a gay fellow, and a member of many clubs, so that he can
seldom be found home of an evening.
I once remonstrated with him, as a true friend should.
"See here," I said, seriously, "you are out every night until the 'wee sma' hours.' Isn't midnight late
enough for you?"
"Well," he replied, "I find when I show up at midnight my wife can talk to me, but when I get home at
three, words fail her."
Say, my wife came home from shopping the other day filled with righteous
indignation, and, of course, while men are not supposed to have any curiosity,
you know, my peace of mind was somewhat disturbed.
I began to have vague fears that perhaps some miserable detective in one of
the department stores might have insulted her—perhaps accused her of having
too warm an affection for the lace counter.
At length, however, seeing that I would not ask the question she was burning
to hear, she burst out with:
"I wish the shopkeepers would be more careful how they put mirrors in
conspicuous places."
"What's the matter? Been trying to dodge your own reflection?" I asked, for do
you know it was the first time I had ever heard a woman complain of too much looking-glass.
"No; but you know there is one of those triple mirrors in one of the department
stores, and poor dear Fido spent fifteen minutes chasing around it trying to
find the other dog. I thought I'd never get him out of that store."
Ever been through the Chinese quarter down around Mott Street, where you
can smell the incense of the joss-sticks burning before the ugly little idols?
I saw in the paper the other day about a fellow who
had come from Korea with samples of idols that he
wanted an American firm to manufacture, and it
begins to look as though presently our enterprising
Yankees might corral this trade along with everything
else.
That gave me an inspiration which I set down in verse—if you'd like to hear the
result I don't mind one bit, so prepare to weep, for here it goes:

The heathen in his blindness


Bows down to wood and stone—
Some idol inexpensive
He puts upon a throne;
But now we'll teach the heathen
The error of his way,
And sell him modern idols
Made in the U. S. A.

We'll lift the foolish heathen


From groping in the dust.
And change and civilize him—
We'll form an Idol Trust.
For ages he has groveled
In superstition dim
But now we'll help his progress
By making gods for him.

No seven-handed figures;
No gods with coiling tails:
No birds, no bugs, no serpents,
No animals, nor whales—
No, sir! He'll have our idols:
A shovelful of coal,
A meter, and an oil can
To terrify his soul.

A bonnet and a ribbon:


A bargain ad.—the strife
They'll cause will make the heathen
Yearn for a better life.
The poor benighted pagan
Will come out of the dark
And bow before our idol—
The mighty dollar mark!

Mr. Carboline, our druggist at the corner, has troubles of his own, though I never realized the fact until I
saw a perspiring individual rush in upon him with a thermometer in his hand the other day, and in an
excited tone exclaim:
"Here, take back this darned machine before I freeze to death."
He looked so heated just then that we began to imagine he must be a little out
of his mind, but Carboline ventured to ask humbly enough what was the
matter with the mercury register.
"It's out of whack somehow, and won't register correctly. Darn it, I've been
shivering in my room for a week, and just couldn't keep warm. I had the
thermometer over my writing desk, and the other morning when the steam
went down a little I looked at the mercury. It showed forty degrees.
"I knew nothing less than a polar bear could work in that temperature, and
went hustling after the janitor.
"He shook up his furnace, and the steam began to sizzle, but the room
wouldn't get warm enough to raise that mercury above 50.
"We ran short of coal for a day, and she went down to 40 again, and I went over to stop with a friend
till we got more coal.
"Then the steam sizzled once more, but the north wind seemed to come in through the window cracks
and the shivers had me all over.
"I struck for window strips, and had a row with the landlord.
"The mercury showed 50 degrees right along, and though I made it hot for the janitor I couldn't get any
of it into the blamed thermometer.
"Yesterday I gave notice that I would get out if they didn't keep me warm. I'm a bachelor tenant paying
a good price and generally no kicker, and they didn't want me to leave.
"About an hour ago the janitor came in to see how I was getting along.
"He found me at my desk with a blanket around me. He asked if I were sick. I told him I was frozen.
"He said he thought the room was very warm. Before licking him I showed him the thermometer and
told him that was the real test.
"The mercury stood at 50.
"The janitor swore and went out.
"He came back in a minute with another thermometer and hung it alongside of
mine. It was a fine one, guaranteed to keep perfect records.
"It marked 65 degrees when he brought it in, and in a minute or two it showed
71. Mine stood still at 50.
"The janitor looked at the two machines and began to grin. I began to unwind
the blanket that was around me. The janitor looked scared, but I told him not
to run; that I wasn't going to lick him. The only man that I felt like licking was
the one who sold me a thermometer that wouldn't go.
"You're the one.
"Now, it's up to you to apologize, give me a machine that is true, or be licked. I've paid my money and
you can take your choice."
Mr. Carboline preferred to make the change.
By the way, before I forget it, let me tell you about young Charlie Suitz, a friend of mine, who is really
as modest a chap as you would care to meet.
Charlie has a girl upon whom he calls very frequently, and, they tell me, at the most unexpected times.
That was probably how it happened he dropped in one afternoon and was informed by her mother that
she was upstairs taking a bath, so he told the old lady he only wanted to speak to her for a minute; and
she called out:
"Mamie, come right down, Mr. Suitz wants to see you down here."
So Mamie called back, "Oh, mother, I can't; I have nothing on."
"Well, slip on something right away, and come down."
And what do you think? Mamie slipped on the stairs, and came down.
Talking of your level-headed young Lochinvars of to-day, who use automobiles in their elopements
instead of horses as in the old times, there was Charlie's brother who fell in love with the only daughter
of old Squeezer, the richest skinflint in Stringtown, and was bound to have her, even if he had to resort
to strategy.
"Oh, Bob," she whispered, sliding down into the outstretched arms of the lover
who stood at the bottom of the ladder, "are you sure the coast is clear?"
"To a dead certainty," he replied, bitterly. "I succeeded in boring a hole in the
water pipe. Your father has discovered it, and will keep his finger over the hole
until the plumber arrives. Come!"
I dined at the Waldorf the other night, and somehow in the long list of courses
found my mind wrestling with an item that had caught my eye in one of the
yellow sheets, where a certain well-known doctor declared that the simple
cooking of savage tribes was far superior to that of the present civilized races.
When I reached home the thought, and perhaps the menu I had so gallantly
assailed, so impressed me, that I sat down and rattled off a few verses
covering the ground. This is how the song goes:

"You cook," I observed to the African chief,


"With a truly remarkable skill;
With your soups and your entrees you ne'er come to grief,
You seldom go wrong when you grill.
Your roast leg of pork or of mutton is—well,
It's a privilege simply to view it;
And I feel I could fatten for weeks on the smell!
How on earth do you manage to do it?"

With a gratified simper the chieftain explained,


"Ah, well, for that matter, the fact is,
Whatever ability I may have gained
Is simply the outcome of practice.
In the days of my youth, e'er I quitted my land,
Not content with the usual rations,
I made it a habit to practice my hand
On my numerous friends and relations.

"I strove with a will toward my ultimate end,


Surmounting each obstacle gayly.
I speedily ran through my circle of friends,
Diminished my relatives daily.
My brothers gave out, and my uncles as well;
My cousins went faster and faster;
Until—in a word a long story to tell—
I found I could cook like a master."

In silence I stood till he came to the end,


For his tale had delighted and thrilled me;
Then thoughtfully thanking my cannibal friend,
I owned that with envy he filled me.
For many's the man whom I'd thankfully boil,
And countless relations beset me,
Whom I'd eagerly stew (without grudging the toil),
If only the law would abet me.
Some people have such remarkable ideas connected with the bringing up of children. There's Rossiter's
young wife for example.
I was invited to an evening dinner party recently where she was the guest of
honor.
This charming young matron is the proud mother of two fine boys, both under
four years of age.
In their education she endeavors to follow a system, like many other young
mothers, and she is very careful to live up to any rules she may have
formulated for them.
During an early course in the dinner, and in the middle of an animated
conversation with her host, she suddenly ceased talking.
Her face took on a most startling expression. Then finding her voice, she
exclaimed:
"Mercy, I have forgotten those boys again! May I use your telephone?"
She was taken to the 'phone by the host, and the murmur of her voice in most earnest conversation
was wafted back to the dining room.
After a short time she returned.
"I beg a thousand pardons," she said, "but you must know I have always insisted that Sam and Dick say
their prayers for me before they go to sleep.
"In the hurry of getting off to-night I entirely forgot my usual duty.
"So I called up the nurse. She brought them to the 'phone and they said their prayers over the wire. I
feel quite relieved."
Speaking of boys reminds me of my friend Toddlekins' young hopeful, who marched into the library the
other day when I was engaging his pa in a scientific discussion.
I may remark just here that Tommy had a new gun under his arm, which I understood his fond parent
had recently presented to him—you know Toddlekins is a great admirer of the strenuous life and likes to
encourage it all he can in his offspring, who appears to be a chip of the old block.
"Say, pa," was what he exploded, "is it true that cats have nine lives?"
Always ready to impart information to the inquiring mind of youth, his fond
parent replied such was the common saying, which might be accepted as truth.
"Well, I am glad of that," said the boy, heaving a genuine sigh of relief,
"because then our old tortoise-shell's got eight coming to her."
I'm afraid my smallest chap is going to take after his proud father—it's about
time, since I've taken after him on many an occasion.
For instance now, at school, in the course of his astronomy lesson, the teacher
happened to ask:
"What supports the sun in the heavens?"
"Why, its beams, of course," was the prompt answer given by the flower of the
family.
He was not encouraged to exercise the propensity further.
But it is not always the boys who can be depended on to furnish material for a good story.
I knew a little tot of a girl once, Helen they called her, the pride and joy of a young couple with whom I
used to dine occasionally in my happy bachelor days.
I discovered, however, one night, that the little lady was very much afraid of the dark, just as some of
her older sisters are prone to be, and all her mother's persuasive eloquence was required to induce the
child to leave the brilliantly lighted dining room for her own dark bedroom.
A whispered colloquy between mother and child finally resulted in the little
one's departure to her room without further protest.
When the mother returned to the dining room she explained:
"It's so easy to handle children if you just know how. I told her there was no
reason to be afraid; that the dark was filled with angels, all watching over her.
Now she is quite content to be left alone and——"
"Mamma! Mamma!" piped a small, far-away voice at this point, "please come
quick. The angels is a-biting me."
While I was talking with Mike who should drop in but
the archbishop?
Now, because a man's a priest is no reason he shouldn't have a big streak of
humor in him, and the archbishop can appreciate a joke as well as the next
one.
They say that when he was up in the Harlem district last winter, for the
purpose of administering confirmation, he asked one nervous little girl what
matrimony was, and she answered:
"A state of terrible torment, which those who enter it are compelled to undergo
for a time to prepare them for a brighter and better world."
"No, no," remonstrated the pastor; "that isn't matrimony; that's the definition of purgatory."
"Leave her alone," said the archbishop; "maybe she's right. What do you or I know about it?"
Thinking to test his knowledge of history, some one once remarked in his hearing:
"I wonder who made the first after-dinner speech?"
"Adam did," replied the archbishop, promptly, "for you know we read that after
he had eaten that apple down to the core, he arose and said, 'the woman
tempted me'."
And you will agree with me he was pretty nearly correct that time.
I always take considerable interest in the yacht races for the America's Cup,
and when my friend Donovan informed me recently that the next boat would
have a wonderful rudder filled with air, to add to the buoyancy and save
weight, I began to consider whether the advantages might not be offset by the
new dangers accompanying a pneumatic rudder.
If a yacht should happen to get a puncture in her rudder during the race she
would be compelled to drop out, owing to the difficulty of cementing or plugging it while sailing.
And in a race a yacht is liable to be on a tack at any moment.
A week ago I took a spin on my wheel, along country roads where the festive
bull loiters in the shade of the tree, waiting for a victim.
If you have ever taken the trouble to notice, there are funny things sometimes
happening on these dusty highways of the hobos, and more than a few times
the shrewd city man finds himself the sport of Rube's wit.
Having become somewhat confused as to my bearings on this particular
occasion, I thought to make inquiries of a slab-sided youth, who leaned on a
fence and sucked at a straw meditatively.
"I say, my good fellow, am I on the right road to Jericho?" I asked, with my
most patronizing smile.
He surveyed me a minute and then said slowly:
"Ya-as, stranger, but I kinder reckon you're goin' in the wrong direcshun."
Say, as I was walking along Sixth Avenue a man thumped me on the back and yelled out:
"Sure, Michael, ye're the broth av a bhoy. Len' me ten."
And I did; I couldn't refuse it. That's like the Irish; they're so hearty and will share your last cent.
There's one bright Irishman that I'm greatly interested in. Terence Sullivan
came over here with the idea that he could pick up money in the streets; and
sure enough the first day he landed he found a nice new ten-dollar bill on one
of the seats in Battery Park. Since then he's gone on doing well.
Sullivan was never much of a reader, and I had often wondered at this until on
a certain occasion he gave his prejudice an airing.
"And faith," said he, "Oi don't see the since in noospapers. They kin only print
what's already happened."
As affairs prospered with the honest fellow, like all true-hearted Irishmen, he
must needs send for the mother, and install her in a comfortable home.
I remember meeting the old lady once, and under conditions that often make
me smile.
I had a friend, a lawyer, who had an office away up in one of the skyscrapers downtown, and here Mrs.
Sullivan, after much persuasion, had been induced to come and pay her rent.
The lawyer's office was on one of the upper floors of a large office building.
After the rent had been paid and the receipt given, the old woman was shown out into the hallway by
the office boy.
I found her in the hallway a few minutes later, when I chanced along. She was
wandering about opening doors and otherwise acting in a strange manner.
"What are you looking for?" I asked.
"Shure," she said, in her simplicity, "I'm lookin' for the little closet I came up
in."
I suppose you will believe me when I tell you that my theatrical ventures have
frequently brought me in contact with ripe episodes that impressed themselves
strongly upon my memory.
Sometimes they were too ripe, and gave occasion for much toil ere they could
be wholly eradicated from my unfortunate coat.
I long ago lost my taste for eggs in any shape.
On a barn-storming crusade with a small show, I remember, at an afternoon
rehearsal, the flute player in the orchestra made me nervous by playing off
key. After vainly endeavoring to correct the man, I lost my temper and
exclaimed:
"Cut out the flute for goodness' sake!"
Thereupon the musician arose with fire in his eye.
"Oh! you want to get rid of the flute, do you?" he asked.
"Yes," I drawled carelessly, "I guess we'll get along all right without your
assistance."
"Oh! you will, will you! Well, see here, young fellow, if I don't play the flute,
you don't sing that song—and there'll be no show to-night. You understand?"
"Who'll prevent?" I demanded.
"Only the flute," was the answer. "I'm the mayor of this place, I am, and I issue the permits. See?"
And I saw.
On my last whirl around the circuit I went by way of the New York Central.
There was a newly-married couple in our car, and of course lots of us were more or less interested in
their carrying-on.
Once the train plunged through a tunnel, and I suppose the newly-made
Benedict took advantage of the golden opportunity to kiss his spouse.
"Morris-sinia!" yelled the brakeman as we came to daylight again.
"I don't care if he did," snapped the woman, "we're married."
At our first stop in a bustling town up in York State I was in the box office,
when I was addressed by a young man who in hollow tones declared he had
heard that to see so great an actor as myself was good for any form of
ailment.
"You might help me," the young man declared with labored breathing;
"anyway, I'd like to enjoy myself once more before I die. I have consumption,
you know. Could you let me have a pass?"
I couldn't help but feel sorry for such a woebegone-looking, hard-luck chap, so
I at once wrote him out a pass.
The man took the card, looked at it, coughed even more distressfully than
before, and asked:
"Couldn't you make it two? I would like to take a friend."
"Has your friend consumption, too?" I asked, solicitously.
"N—no—not yet," faltered the man.
"Ah! then, I'm afraid I can't accommodate your friend. You see, I never give
passes except to persons with the consumption."
Some people think there is little in a name, but I'm a great believer in an
attractive title. I could mention scores of reasons for thinking as I do, and you can better believe I'm not
alone in this thing.
Passing the Academy of Music a short time ago, one matinee day, I met my friend Shackleford coming
out, and the play only half over.
"What is the matter?" I asked; "play bad?"
"No," he replied, "but it is too hot in there; the house is literally packed with women. You see it's the
name—'Ninety and Nine'—that catches them. Why, it's better than an actual horse-race or a locomotive,
to draw. They fancy that the admission has been marked down from a dollar and can't resist the
bargain."
Whenever I meet Chauncey Billings on Broadway the sparks are sure to fly in the fireworks display of
dry wit that passes between us, just as though you struck flint and steel smartly.
The other day he approached, looking very happy, as though anticipating overwhelming me, so being
forwarned I prepared to resist boarders.
"My dear Niblo," said he, "you will be surprised to learn I've taken up a new
business."
"Indeed, What are you now?" I asked.
"I'm a detective in a pool room."
"What do you do?"
"Oh, I spot balls."
"That's nothing," I remarked, casually, "I used to work in a cheese factory."
"And what did you do?"
"Oh, play baseball."
"What, baseball in a cheese factory, Mr. Niblo!"
"Sure, I used to chase flies. That got tiresome and I went to work in a barber shop."
"What were your duties there?"
"I used to mix lather."
"And what did you mix lather for?"
"Oh, to lather Irishmen and Dutchmen, etc."
"I have a brother who works in an eye hospital," said Chauncey, soberly.
"What does he do?"
"Oh, he makes goo-goo eyes."
"That's nothing, I have a sister who works in a watch factory making faces."
And so we pass the retort discourteous, and exchange pleasantries as only old
friends may.
In the Catskill village, where we delight to spend a portion of the heated term
and all our hard-earned capital, there is a boarding-house run by an eccentric
genius, who knows how to set a good table and never has an empty room
through the season, though over the gate leading up to his hotel he has
painted a sign that might well cause consternation in the breast of many a
would-be sojourner, for it reads:
"Boarders taken by the day, week or month. Those who do not pay promptly
will be taken by the neck."
There were some rumors floating around that this
remarkable Boniface, as a Christian Science advocate, had been benefited to
an astonishing extent in the recovery of his health.
Being of an investigating turn of mind, and anxious to learn all that was
possible concerning the latest fad, I cornered old Bijinks out near the hog-pen
and engaged him in conversation, during which he made a positive assertion
that rather staggered me.
"Do you mean to tell me that you actually believe Christian Science cured
you?" I demanded, eagerly.
"Sure," he said, nodding.
"Of appendicitis?"
"B'gosh, no—of Christian Science."
There was a crusty old bachelor at the house who got disgusted with the spoony couples and came up
to my room to talk it over with me.
"What is love, anyway?" he demanded.
"Intoxication," I answered, unguardedly.
"Right," he quickly said, "then possibly marriage must be delirium tremens."
Before I could recover my breath he fired another hot shot at me.
"There's three things I never could stand if I ever married."
"And what are they?" I asked.
"Triplets."
I tried to give him the old gag about a woman's heart being a gold mine.
"That's right," he said; "you've got to prospect it before you find out what it's worth; and I know a
whole lot of fellows who've gone broke prospecting."
That landlord of ours up in the glorious Catskills was a hard subject to catch napping, and many a time
I've watched him crawl out of a hole with hardly an effort.
Probably it requires considerable nerve to run a summer resort hotel, and meet all the requirements
which the traveling public seem to expect.
On one occasion I heard a tourist who had just arrived ask him the old chestnut:
"Is this a good place, landlord, do you think, for a person affected with a weak chest?"
"None better, sir, none better."
"I've been recommended, you know, by the doctor, to spend the summer in some mountain region
where the south wind blows. Does it blow much here?"
"Why sure, it's always the south wind that blows here," replied the landlord,
stoutly.
"Ah, indeed, then how do you account for it blowing from the north just now?"
"That's easy enough, sir—you see it's the same old south wind on its road back
again."
That landlord was a jewel, and afforded me considerable entertainment during
my sojourn; but he had a neighbor, a stout German farmer, who took the cake
when it came to doing business.
Le'me tell you about his experience with the insurance agent, for it was
certainly laughable, though old Platzenburger didn't see it that way.
It seems that the house of the farmer, insured for a thousand dollars, had burned down. The privilege
of replacing a burned house is reserved by insurance companies and the agent, having this in mind,
said to the farmer:
"We'll put you up a better house than the one you had for six hundred dollars."
"Nein!" said Platzenburger, emphatically. "I vill have my one tousand dollar or notings! Dot house could
not be built again for even a tousand."
"Oh, yes, it could," said the insurance man. "It was an old house. It doesn't cost so much to build
houses nowadays. A six-hundred-dollar new house would be a lot bigger and better than the old one."
Some months later, when the insurance man was out for a day's shooting, he rode up again to the
farmer's place.
"Just thought I'd stop while I was up here," he said, "to see if you wanted to take out a little insurance."
"I got notings to insure," said Platz, "notings but my vife."
"Well, then," said the insurance man cheerfully, "insure her."
"Nein!" said the farmer, with determination. "If she die, you come out here and
say, 'I not give you one tousand dollar. I get you a bigger und a better vife for
six hunded.' No, sir, I dakes no more insurance oud!"
You must excuse me if I have to call a temporary halt upon these proceedings
and indulge in a little vociferous sneeze, for a cold in the head is no respecter
of persons. This is the sneeze, sung in a sad, sobbing minor:

I've got a cold with snuffles in;


What kind of a cold have you?
I've got the kind that makes me sin
By craving fizzes made of gin
And other stuff with bad booze in—
What kind of a cold have you?

I've got the kind that makes one hoarse;


What kind of a cold have you?
To speak requires my utmost force;
My voice is rough, and harsh, and coarse,
And strains its laryngital source—
What kind of a cold have you?

I've got a cold that makes me mad—


What kind of a cold have you?
That makes me reticent and sad,
That puts me plainly to the bad,
The worstest cold I ever had—
What kind of a cold have you?
I suppose you know I was on a tour in Florida and other parts of the Sunny South last winter?
There is a tradition down there that if a mule kicks a darky on the head the wretched mule is sure to go
lame.
When I was down there I happened to notice a little colored girl limping along the street, her feet done
up in immense bandages of sacking.
"What's the matter with your feet?" was my natural inquiry.
"My fadder done hit me on de haid while I was standin' on an iron cellar door,"
was the response.
When I got to Charleston there was a circus in town, and after doing my
matinee stunt at the local theatre, I got around to the circus.
There was a pretty fair menagerie along with the show, and it was a treat to
me to stand around and hear the original and quaint remarks of the negroes,
many of whom had never before in their lives seen lions and elephants.
One big ugly gorilla seemed to attract them above all other living curiosities,
and he was a fierce sight, I assure you.
I saw an old wizened-up aunty stand in front of his cage a long time, speechless with awe, and finally
heard her vent her feelings in the words:
"Foah massa sakes alibe, if he ain't jest like de ole-time culled folks."
Another queer old chap tried to make the acquaintance of the uncouth and hairy monster.
"How is you?" said the old black man, bowing before the monstrous ape.
No answer.
"How is you?" Eph repeated, with another profound bow, and still no answer. Then, after a long pause,
Eph exclaimed:
"You's right, ole man; keep yo' mouf shet or dey'll put a hoe in yo' hand and make yo' raise cotton."
The menagerie always fascinates me. Why, I'm just like a boy again when I get among the animals, and
catch that well-remembered odor always connected with a show.
I've even dreamed about 'em, and strange as it may appear, they always seem to be passing before me
in a great hurry, just as though on a wager.
As I say, I was kind of fascinated and thinking of boyhood's days and all that sort of thing, you know,
when some one spotted me.
"By de great horn spoon, if dar ain't George Niblo!"
I tried to look shy and turned on my best blush.
Then the manager turned to me politely, gave me the glad hand and asked if I wouldn't sing a little
song.
I said "sure"; and I did. Here's the song I sung:

The animals thought they would have a race;


The Monkey was referee;
The Bull was stakeholder, for, as he said,
It was his nature to be.
The Camel got a hump on himself;
The Lion ran with might and mane;
The Tiger stood off, for a beast of his stripe
Was not let to enter again.
The Elephant took his trunk along,
In case he won the prize;
The Peacock was starter, and missed no one,
For, you see, he was all eyes.
Some spotted the Leopard for winner sure;
The old ones chose the Gnu;
While those who leap to conclusions quick
Bet on the Kangaroo.
The Ostrich plumed himself on his speed;
All tried the record to wreck;
The Hippopotamus blew his own horn,
But the Giraffe, he won by a neck.
I was in court the other day.
There is no use of any vulgar curiosity concerning the reason of my being present; but I will say right
here that I won my case, and when a fellow does that he's all right. Yes, sir; I had the dough with me.
While I was waiting my turn a disreputable-looking chap was brought before the judge, I believe
charged with vagrancy or something of the sort.
"What is your name?" inquired the justice.
"Pete Smith," responded the vagrant.
"What occupation?" continued the court.
"Oh, nothing much at present; just circulatin' round."
"Retired from circulation for thirty days," pronounced the court, dryly.
In another case where one of the witnesses had been severely baited by a
counsel, the question arose as to the authenticity of a letter of which the
witness was reputed to be the author.
"Sir," said the lawyer, fiercely, "do you, on your oath, swear that this is not your
handwriting?"
"I think not," was the reply.
"Does it resemble your handwriting?"
"I can't say it does."
"Will you swear that it does not resemble your handwriting?"
"I will."
"You will positively take your oath that this writing does not resemble yours?"
persisted the lawyer, working himself into a state bordering on frenzy.
"Ye-s-s, sir."
"You seem less positive," remarked his interrogator; "perhaps we had better have a specimen of your
handwriting for purposes of comparison."
The witness caused it to be understood that this was impossible, whereupon the lawyer, scenting his
approaching triumph, smiled serenely at the court.
"Oh, sir, it is impossible, is it? And may I ask why?"
"'Cause I can't write," returned the man.
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