100% found this document useful (5 votes)
283 views

Learn iOS 11 Programming with Swift 4 Craig Clayton all chapter instant download

Learn

Uploaded by

forberrofyda
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 (5 votes)
283 views

Learn iOS 11 Programming with Swift 4 Craig Clayton all chapter instant download

Learn

Uploaded by

forberrofyda
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/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Learn iOS 11 Programming with Swift 4 Craig


Clayton

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

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

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/

textboxfull.com

iOS 11 by Tutorials Learning the new iOS APIs with Swift 4


1st Edition The Raywenderlich Tutorial Team

https://textbookfull.com/product/ios-11-by-tutorials-learning-the-new-
ios-apis-with-swift-4-1st-edition-the-raywenderlich-tutorial-team/

textboxfull.com

iOS 11 Swift Programming Cookbook Solutions and Examples


for iOS Apps 1st Edition Vandad Nahavandipoor

https://textbookfull.com/product/ios-11-swift-programming-cookbook-
solutions-and-examples-for-ios-apps-1st-edition-vandad-nahavandipoor/

textboxfull.com

Learn Swift by Building Applications Explore Swift


programming through iOS app development 1st Edition Emil
Atanasov
https://textbookfull.com/product/learn-swift-by-building-applications-
explore-swift-programming-through-ios-app-development-1st-edition-
emil-atanasov/
textboxfull.com
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/

textboxfull.com

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/

textboxfull.com

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/

textboxfull.com

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/

textboxfull.com

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/

textboxfull.com
Learn iOS 11 Programming with Swift 4
Second Edition

Learn the fundamentals of iOS app development with Swift 4 and


Xcode 9

Craig Clayton

BIRMINGHAM - MUMBAI
Learn iOS 11 Programming with
Swift 4 Second Edition
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.

Acquisition Editor: Reshma Raman


Content Development Editor: Vikas Tiwari
Technical Editor: Madhunikita Sunil Chindarkar
Copy Editor: Muktikant Garimella
Project Coordinator: Ulhas Kambali
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Graphics: Jason Monteiro, Tom Scaria
Production Coordinator: Shantanu N. Zagade

First published: December 2016


Second edition: January 2018

Production reference: 1290118

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78839-075-0

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over 5,000
books and videos, as well as industry leading tools to help you plan your
personal development and advance your career. For more information,
please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks
and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


PacktPub.com
Did you know that Packt offers eBook versions of every book published,
with PDF and ePub files available? You can upgrade to the eBook version
at www.PacktPub.com and as a print book customer, you are entitled to a
discount on the eBook copy. Get in touch with us at [email protected] for
more details.

At www.PacktPub.com, you can also read a collection of free technical articles,


sign up for a range of free newsletters, and receive exclusive discounts and
offers on Packt books and eBooks.
Contributors
About the author
Craig Clayton is a self-taught, senior iOS engineer at Adept Mobile
specializing in building mobile experiences for NBA and NFL teams. He
also volunteers as the organizer of the Suncoast iOS meetup group in the
Tampa/St. Petersburg area, and prepares presentations and hands-on talks
for this group and other groups in the community. He has also launched
Cocoa Academy online, which specializes in bringing a diverse list of iOS
courses ranging from building apps to games for all programming levels.
About the reviewer
Cecil Costa, also known as Eduardo Campos in Latin countries, is a Euro-
Brazilian freelance developer. He has been giving onsite courses for
companies such as Ericsson, Roche, TVE (a Spanish TV channel), and
others. He has also worked for different companies, including IBM,
Qualcomm, Spanish Lottery, and Dia. He is also the author of Swift
Cookbook, Swift 2 Blueprints, Reactive Programming with Swift, and a
video course called Building iOS 10 Applications with Swift, by Packt
Publishing.
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit authors.pac
ktpub.com and apply today. We have worked with thousands of developers
and tech professionals, just like you, to help them share their insight with
the global tech community. You can make a general application, apply for a
specific hot topic that we are recruiting an author for, or submit your own
idea.
Table of Contents
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
1. Getting Familiar with Xcode
Getting started
The Xcode interface
Navigator panel
Standard editor
Utilities panel
Debug panel
Toolbar
Generic iOS device
iOS device
Connecting wirelessly
Window pane controls
Summary
2. Building a Foundation with Swift
Playgrounds – an interactive coding environment
Data types – where it all starts
String
Integer data type
Floating-point numbers
Booleans
Variables and constants – where data is held
Creating a variable with a string
Creating a variable with an integer (Int)
Debug and print() – detecting your bugs
Adding floating-point numbers
Creating a Boolean
Hungarian notation
Why constants versus variables?
Comments – leaving yourself notes or reminders
Type safety and type inference
Concatenating strings
String interpolation
Operations with our integers
Increment and decrement
Comparison operators
Summary
3. Building on the Swift Foundation
Creating a Playground project
The if statements – having fun with logic statements
Optionals and optional bindings
Why optionals?
Functions
Summary
4. Digging Deeper
Creating a Playground project
Ranges
Closed range
Half-closed range
Control flow
The for...in loop
One-sided range
The while loop
The repeat...while loop
Summary
5. Digging into Collections
Arrays
Creating an empty array
Creating an array with initial values
Creating a mutable array
Adding items to an array
Checking the number of elements in an array
Checking for an empty array
Retrieving a value from an array
Iterating over an array
Removing items from an array
Dictionaries
Creating a dictionary
Adding and updating dictionary elements
Accessing an item in a dictionary
Iterating over dictionary values
Iterating over dictionary keys
Iterating over dictionary keys and values
Checking the number of items in a dictionary
Removing items from a dictionary
Sets
Creating an empty set
Creating a set with an array literal
Creating a mutable set
Adding items into a set
Checking if a set contains an item
Iterating over a set
Intersecting two sets
Joining two sets
Removing items from a set
Summary
6. Starting the UI Setup
Useful terms
View Controller
Table View Controller
Collection View Controller
Navigation Controller
Tab Bar Controller
Storyboard
Segue
Auto Layout
Model View Controller (MVC)
App tour
Explore tab
Locations
Restaurant listings
Restaurant detail
Map tab
Project setup
Creating a new project
Summary
7. Setting Up the Basic Structure
Starting from scratch
Storyboard setup
Adding our app assets
Storyboards
Creating our launch screen
Adding a Navigation Controller
Summary
8. Building Our App Structure in Storyboard
Adding a Collection View Controller
Hooking up our outlets
Creating a custom color
Setting up our cell
Section header
Updating the grid
Adding a modal
Updating Bar Button Items
Unwinding our Cancel button
Adding our first Table View
Summary
9. Finishing Up Our App Structure in Storyboard
Adding our Restaurant List View
Hooking up our outlets
Setting up our cell
Adding Reviews View
Viewing reviews
Map Kit View
Summary
10. Designing Cells
Setting up the Explore header
Adding Auto Layout to the Explore header
Setting up the Explore cell
Adding Auto Layout to the Explore cell
Setting up the Restaurant cell
Adding Auto Layout to the Restaurant cell
Location cell
Summary
11. Designing Static Tables
Setting up cells
Creating our section headers
Creating our address section
Adding Auto Layout to the headers
Photos section
Adding Auto Layout to the photos section
Reviews section
Adding Auto Layout to the Review cells
Updating the reservation times cells
Reservation information
Reservation header
Summary
12. Designing a Photo Filter and Review Form
Setting up our View Controllers
Adding our Photo Filter View
Adding Auto Layout for the Photo Filter View
Creating the Photo Filter View cell
Adding Auto Layout to our Photo Filter cell
Creating reviews
Setting up the Review storyboard
Creating a Review form
Updating the Review cells
Updating our first cell
Positioning UI elements
Adding Auto Layout for creating reviews
Refactoring the storyboard
Creating a new storyboard for the Map tab
Creating a new storyboard for the Explore tab
Summary
13. Getting Started with the Grid
Understanding the Model View Controller architecture
Getting familiar with the setup
Classes and structures
Controllers and classes
Creating our controller
Understanding Collection View controllers and Collection View
cells
Getting data into Collection View
Understanding the data source
Summary
14. Getting Data into Our Grid
Model
ExploreData.plist
ExploreItem.swift
ExploreDataManager.swift
Getting data
Connecting to our cell
Hooking up our UI with IBOutlets
Restaurant listing
Summary
15. Getting Started with the List
Creating our Location View Controller class
Connecting our Table View with our Location View Controller
Digging into our Table View code
Adding the data source and delegate
Adding locations to our Table View
Creating our first property list (plist)
Adding data to our property list
Creating our location data manager
Working with our data manager
Creating folders
Summary
16. Where Are We?
Setting up map annotations
What is an MKAnnotation?
Creating a restaurant annotation
Creating our Map Data Manager
Creating a base class
Refactoring code
Refactoring ExploreDataManager
Creating and adding annotations
Creating our Map View Controller
Creating custom annotations
Map to restaurant detail
Creating a storyboard reference
Map to restaurant detail
Passing data to restaurant detail
Organizing your code
Refactoring ExploreViewController
Using the MARK comment
Refactoring RestaurantViewController
Refactoring MapViewController
Summary
17. Working with an API
Creating an API Manager
What is an API?
Understanding a JSON file
Exploring the API Manager file
Location list
Selecting a location
Adding a Header view
Passing a selected location back to Explore View
Unwinding our Done button
Getting the last selected location
Passing location and cuisine to the restaurant list
Creating our restaurant cell class
Setting up restaurant list cell outlets
Creating a restaurant data manager
Handling no data
Summary
18. Displaying Data in Restaurant Detail
Adding a navigation button
Displaying data in our static Table View
Summary
19. Foodie Reviews
Getting started with reviews
Displaying ratings in our custom UIControl
Adding our touch events
Setting up the unwind segues
Setting up our rating control
Creating our review form controller
Summary
20. Working with Photo Filters
Understanding filters
Creating our filter scroller
Creating a filter cell
Creating our apply filter view controller
Getting permission
Summary
21. Understanding Core Data
What is Core Data?
Creating a data model
Entity auto-generation
Restaurant Photo Entity
Review item
Core Data manager
Summary
22. Saving Reviews
Saving reviews
Saving photos
Setting up the cell UI
Adding Auto Layout
Adding an overall rating
Summary
23. Universal
Explore
Location listing
Restaurant listing
Updating restaurant details
Summary
24. iMessages
Understanding iMessages
Creating our extension
Updating our assets
Implementing our Messages UI
Adding Auto Layout to our cell
Creating a framework
Connecting our message cell
Showing restaurants
iMessage crashing
Sending reservations
Summary
25. Notifications
Starting with the basics
Getting permission
Setting up notifications
Showing notifications
Customizing our notifications
Embedding images
Adding buttons
Custom UI in notifications
Summary
26. Just a Peek
Adding 3D Touch quick actions
Adding favorites
Creating a new model object
Updating our Core Data manager
Summary
27. Drag and Drop
Accepting drag from other apps
Dragging and dropping filter items
Summary
28. SiriKit
Understanding SiriKit
Supported intents
Enable Siri capabilities
Creating users
Updating our intent handler
Testing Siri
Summary
29. Beta and Store Submission
Creating a bundle identifier
Creating a certificate signing request
Creating production and development certificates
Creating a production provisioning profile
Creating a Development Provisioning Profile
Creating an App Store listing
Creating an archive build
Internal and external testing
Internal testing
External testing
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Preface
In this book, we will build a restaurant reservation app called Let's Eat. We
will start the book off by exploring Xcode, our programming environment,
which is also known as Interface Development Environment (IDE). Next,
you will start learning the foundations of Swift, the programming language
used in iOS apps. Once we are comfortable with the basics of Swift, we will
dig deeper to build a more solid foundation.

After we have a solid foundation of using Swift, we will start creating the
visual aspects of our Let's Eat app. During this process, we will work with
storyboards and connect our app's structure together using segues. With our
UI complete, we will go over the different ways in which we can display
data. To display our data in a grid, we will use Collection Views, and to
display our data in a list, we will use Table Views.

We will also look at how to add basic and custom annotations on to a map.
Finally, it's time to get real data; we will look at what an Application
Programming Interface (API) is and how we can get real restaurant data
into our Collection Views, Table Views, and Map.

We now have a complete app, but how about adding some bells and
whistles? The first place we can add a feature will be on the restaurant
detail page where we can add restaurant reviews. Here, users will be able to
take or choose a picture and apply a filter on to their picture. They will also
be able to give the restaurant a rating as well as a review. When they are
done, we will save this data using Core Data.

Since we built our app to work on both iPhone and iPad, we should add the
ability to make our app support iPad Multitasking. Doing this will allow our
app to be open alongside another app at the same time.

If we want to be able to send our reservation to a friend, we can create a


custom UI for iMessages, which will send them the details for the
reservation along with the app it came from. The one thing missing from
our app is the ability to notify the user with a custom notification to alert
when they have an upcoming reservation.

Finally, let's create a quick access for our app using 3D touch where, by
tapping our app icon, the user can quickly jump to their reservations. Now
that we have added some bells and whistles, let's get this app to our friends
using TestFlight,
and finally get it into the App Store.
Who this book is for
This book is for beginners who want to be able to create iOS applications. If
you have some programming experience, this book is a great way to get a
full understanding of how to create an iOS application from scratch and
submit it to the App Store. You do not need any knowledge of Swift or any
prior programming experience.
What this book covers
Chapter 1, Getting Familiar with Xcode, takes you through a tour of Xcode
and talks about all the different panels that we will use throughout the book.

Chapter 2, Building a Foundation with Swift, deals with the basics of Swift.

Chapter 3,Building on the Swift Foundation, teaches us to build on our


Swift foundation and learn some more basics of Swift.

Chapter 4, Digging Deeper, talks about ranges and control flow.

Chapter 5,Digging into Collections, talks about the different types of


Collections.

Chapter 6,Starting the UI Setup, is about building the Let's Eat app. We will
focus on getting our structure set up using storyboards.

Chapter 7, Setting Up the Basic Structure, deals with working on our Let's
Eat app in a storyboard.

Chapter 8, Building Our App Structure in Storyboard, is about adding more


to our app structure in the storyboard

Chapter 9, Finishing Up Our App Structure in Storyboard, finishes up our


app structure in the storyboard

Chapter 10, Designing Cells, is about designing the table and collection view
cells in storyboard.

Chapter 11, Designing Static Tables, teaches how to work with a static table
view.

Chapter 12,Designing a Photo Filter and Review Form, teaches you how to
design a basic form.
Chapter 13,
Getting Started with the Grid, is about working with Collection
Views and how we can use them to display a grid of items.

Chapter 14, Getting Data into Our Grid, is about getting data into our
Collection Views.

Chapter 15,Getting Started with the List, teaches us to work with Table
View and takes a deep look at dynamic Table Views.

Chapter 16,Where Are We?, deals with working with MapKit and learning
how to add annotations to a map. We will also create custom annotations for
our map.

Chapter 17, Working with an API, is about learning how to use a JSON API
within our app.

Chapter 18, Displaying Data in Restaurant Detail, teaches you how to pass
data using segues.

Chapter 19, Foodie Reviews, talks about working with the phone's camera
and library.

Chapter 20,Working with Photo Filters, takes a look at how to apply filters
to our photos.

Chapter 21, Understanding Core Data, teaches us the basics of using Core
Data.

Chapter 22, Saving Reviews, wraps up Reviews by saving them using Core
Data.

Chapter 23,Universal, deals with multitasking on the iPad, and how we can
get an update to be supported on all devices.

Chapter 24, iMessages, is about building a custom message app UI. We will
also create a framework to share data between both apps.
Chapter 25, Notifications, provides learning on how to build basic
notifications. Then, we will look at embedding images into our notifications
as well as building a custom UI.

Chapter 26, Drag and Drop, is about learning how to add drag and drop both
within the app and accepting drag and drop from other apps.

Chapter 27, Just a Peek, looks at 3D touch and how to add quick actions to
our app. We will also look at how we can add peek and pop to our
restaurant list.

Chapter 28, SiriKit, teaches how to use Siri to create money requests.

Chapter 29, Beta and Store Submission, is about how to submit apps for
testing as well as submitting apps to the App Store.
To get the most out of this book
You need to have Xcode 9 installed in your system. To download Xcode 9
visit https://developer.apple.com/xcode/.
Download the example code
files
You can download the example code files for this book from your account
at www.packtpub.com. If you purchased this book elsewhere, you can visit www.
packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

1. Log in or register at www.packtpub.com.


2. Select the SUPPORT tab.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box and follow the onscreen
instructions.

Once the file is downloaded, please make sure that you unzip or extract the
folder using the latest version of:

WinRAR/7-Zip for Windows


Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.co
m/PacktPublishing/Learn-iOS-11-Programming-with-Swift-4-Second-Edition. We
also have other code bundles from our rich catalog of books and videos
available at https://github.com/PacktPublishing/. Check them out!
Exploring the Variety of Random
Documents with Different Content
Sometimes you will find the beak of a swimming bird telling a
different story. It will be a very strong beak, with notches along it. It is
a fish-eating swimmer. Its rough bill is to hold fast to the slippery fish.
Then, too, you may find webbed feet which have a new story to tell.
You may find a webbed foot, quite small, with a very long leg. The
web goes only part way to the toe nail. That bird could not swim. No.
He was a wading bird.
His long stilt-like legs held his body above the water, while he
watched for his fish food. The webs in his feet served, not to make
him a paddle-foot, but just to keep him from sinking in the soft sand
or mud. Or you may find the webs changed to broad flaps on each
toe.
Now turn to the hen. Is her beak made for digging in mud, under
water? No. Her short, strong beak is for picking up grain or insects
from the ground. Now see what feet she has to match this beak. She
has walking feet. Her feet are large and strong, with separate toes
and strong nails. How does she use her feet? She spends nearly all
her time scratching and digging in the ground. She scratches up the
earth with her toes. She finds insects, worms, larvæ, and such
things, to eat.
Once more look at a beak. Take the swallow’s short, wide, widely
opening beak. Watch the swallow as he flies. Now up, now down!
Now here, now there! He wheels, he makes a dash! He feeds upon
the wing. He eats insects. See that short, broad mouth, which opens
as wide as his whole head, and shows his big yellow throat. Is it not
just the thing for catching insects?
The swallow sweeps after the insect, and into that open throat it
goes! What story will this beak tell?
The story of a bird made for flying fast and far. The story of a bird
built to wheel and turn quickly. It must have large wings, a very light
body. As its head is so wide, it must be flat, or it will be too large.
This bird does not need to walk. Its food is in the air. Its legs and feet
will be very small. Its toes will be long, and made for holding or
clinging to trees or roofs. Its feathers must be close set; and its tail
be well shaped for a rudder.
Suppose some one shows you the foot of an ostrich. It is a huge
foot, with two great toes. You will say at once “that is a walking foot.”
It is not to be carried into the air. These great toes are not for
digging, but for walking or running.
Look at the soles of these toes. They are cushioned or padded thick.
That bird must live where the soil is soft, and these padded feet will
keep him from sinking. Yes, he lived on the desert sand. He is the
largest bird in the world. He can run faster than a horse. Such a bird
could not be lifted into the air on wings. He has short, stout wings,
which he flaps as he runs, and as they have large feathers on them,
they catch the air as sails do, and so help him along.
His bill is like a huge hen’s bill. He eats melons, grass, and grain.
These are some of the stories told by beaks and feet.
LESSON XXX.
TREE, GROUND, AND WATER BIRDS.
In old times they told fables of birds which had no feet, and lived
always on the wing. There are no such birds. All birds have feet, all
rest from flying. But the motion of flying is so beautiful and easy, that
it is no wonder that birds of strong flight are much upon the wing.
The eagle and hawk families are very swift of flight, and spend most
of their time mounting and wheeling. They are keen of sight, and
from great heights will see their prey, and swoop down upon it.
The swallow family seems never tired of flying. They feed upon the
wing. The tiny humming-birds move their wings so quickly, you
cannot see them. They hover with this motion while they drink honey
from flowers. They are very seldom seen resting.
Pigeons are among our swiftest birds. Have you noticed how thirsty
pigeons are? That is because they are very hot blooded. They need
much hot blood to warm up in their lungs the air which they drive
through their hollow bones. Thus they make a kind of balloon of their
bodies. The pigeon’s body helps to keep it up in the air.
Many of the birds that live much on the wing build their nests on or in
trees. I shall tell you a little of nests in another lesson. Now we will
speak of one or two tree-living birds.
The butcher bird, or shrike, is about the size of a robin. It is a pretty
bird, gray or brown in color. Its food is living things, as beetles, bees,
mice, and young birds. It has a very curious habit. It brings home
part of its food, and hangs it on a thorn near its nest.
The butcher bird chooses trees with thorns or sharp twigs, and
makes its nest among them. Then on the thorns, all about the nest, it
hangs insects and little animals. I saw one of these nests once,
about which hung a young bluebird, a beetle, three bees, and a big
AT THE POND.

spider.
I have thought it may hang up little dead animals partly as a trap for
big blue-bottle flies. For these flies cluster about the dead bodies,
and the shrike, keeping guard near his nest, picks them up at his
ease.
A much nicer bird, one which I wish lived in our country, is the bower
bird. This bird makes its nest in a tree, but fashions a little arbor for
itself, among the grasses. Into its grass palace it brings all the pretty
things it can find. Shells, bright stones, bits of cloth, glass, bones,
flowers, are all brought to its little play-house. Would you not love a
bird which had such pretty ways?
Of all the birds in our own land, none is more splendid than the
cardinal bird of the South. He has a crimson beak and plumes. His
song is very sweet. He is a brave bird, and very kind and polite to his
mate. It is very cruel to kill such a creature for its feathers.
In the North, we have the blue jay, nearly as fine a bird as the
cardinal. He has a jet-black collar, a bright coat of shaded blue, and
a white neck-tie. Indeed, he is a fine, gay, saucy, cheerful bird. But
he has a very naughty way of breaking up the nests of other birds,
and stealing their eggs.
The jay likes to have his home near the water, and when you go near
it, he comes out and scolds loudly.
But now we will turn from birds which make their homes in trees, and
look a little at birds that live on the ground. You will at once think of
the barn-yard fowls, and their many cousins.
Have you seen a barn-yard full of these birds? It is a fine sight.
There are the spotted guinea fowls with their fretful cry, and the great
peacocks spreading their splendid trains. There are the black, white,
yellow, spotted, red, and green-breasted cocks and hens, and there
are pheasants which seem to be dressed in rainbows.
Among these fowls the turkey struts, spreading his tail like a wheel,
and scraping the tips of his wings on the ground, as he walks high on
his toes. Far out in the Western woods, you may see the wild turkey,
which is nearly as fine a bird as a pheasant or a peacock.
Turkey hens are very good mothers. They seem very fond of their
little ones, and are always on the watch to guard them. By nature
they are shy birds, and like to run away, and hide their nests. One
will go off and hide a nest, and seem very proud to come back with a
train of fifteen or more little ones.
Grouse, partridges, and quails, are ground-living birds, related to our
common fowls. So are the pretty prairie-hens of the West. The quail
is a dear little bird. Sometimes in the winter, when the snow is deep,
and it cannot find food, it will come to the barn-yard or the door-step,
and feed with the fowls. Once, in the woods, I came softly to an
opening, and there were about twenty quails feeding on a bed of
squaw-berries. They ran about picking up berries and making happy
little sounds, like a band of children enjoying a holiday.
One day I was going through a pine-wood path, when a mother quail
and ten little ones ran across the roadway. She hid in the brush, and
began to call, “Come! Come! Come!” and from the other side of the
path, little squeaks replied, “Yes! Yes! Yes!”
Soon three more brown, fluffy balls ran across the road. Then out ran
the little brown mother in great distress. Her neck feathers stood out
in a collar. “Come! come! come!” she called. “Wee! wee! wee!” said a
little faint voice, and tumbling along the foot path, went one more
small bird. “Now she has them all,” I thought.
But still, out of the brush, the anxious mother cried, “Come! come!”
and at last, dropping into ruts, rolling in the dust, too new and weak
even to say, “Wee,” hardly able to keep on his legs, went the tiniest
little bird! He followed his mother’s voice, and slipped in among the
brush and pine needles.
When the little brown mother had all her brood, she made a sweet,
low, glad note in her hiding place. “O Mrs. Quail!” I cried; “can you
count? Can you count fifteen?” She never told me whether she could
or not. But she had counted fifteen that time, that was sure.
Now, let us take a peep at the birds which live mostly on the water;
you will think first of the great, solemn white swans. Then of the
snowy geese and of the parti-colored ducks. What splendid colors
ducks have!
If you live by the sea, you will often watch the gulls and gannets with
their wide white wings. All these birds build their nests in reeds and
grass along the bank, or in ledges of rock in a cliff.
One day I was sitting behind some rocks on a little island. All at once
I heard a hearty laugh. I rose up softly, and looked over the rocks.
There on the water sat, all alone, a water-fowl. I hid my head and
gave a loud “ha! ha! ha!”
Then the bird threw back his head, and gave a laugh with all its
might. It made me think of what my grandfather used to say to the
boys, if they were too loud in their mirth for his taste. “Do not laugh
like a loon,” he would say.
Is it news to you that a bird can laugh? The water-fowl and I laughed
at each other for a long time. Then I rose and stood in plain sight.
Down he went under the water, and I saw him no more. I wish you
would read a lovely poem written by the poet Bryant, about “The
Water-fowl.”
Once I was out on the sea in a boat. We saw lying on the water the
tail of a fish. We rowed near. Well! Here was a sight! A large duck,
called an alwife,[25] had tried to swallow a fish. But the fish was too
big for her throat. Having got part of it in, she could get the fish
neither in nor out. So she and the fish had both choked to death, and
were floating around in the water.
A very famous man once said, that he thought a gull must be the
most happy of birds. It can swim, fly, walk, almost equally well. It is at
home on earth, water, or air.
I have seen a bird called “The Diver.” It goes down under water for
its food. It uses its wings under water to swim with, and will stay
there a long time. Most ducks will dive, and come up a long way from
where they went down.
The water birds all have close, thick plumage. Most of the down
which we use, comes from the water birds of the far North. The down
not only keeps them warm, but keeps air in its meshes, and helps
them to float. It is like a cork jacket for them.
Water birds live chiefly on fish, crabs, and little water animals. But
many of them eat seeds and berries of plants growing along the
coast. They will readily pick up any kind of food thrown upon the
water. Gulls follow ships for days to get the scraps thrown overboard
by the sailors.
FOOTNOTES:
[25] Alwife is probably a short form of “Old Wife.” This duck is
often called the “Old Squaw” on the Cape Cod coast.
LESSON XXXI.
ON THE WING.
In the spring and summer, you go to field and garden, and you hear
and see many birds. As you walk about the woods, you may see a
dozen kinds of birds in a few minutes. There will go a yellow-bird,
looking like a canary. There, all splendid in black and gold, an oriole
is busy building his curious nest. There flies from the swamp a red-
wing blackbird. A big woodpecker drums on the nearest tree. A
bluebird with a russet breast sits singing on the top rail of a fence.
Sparrows, swallows, crows, are everywhere.
Out of the grass whirrs up a lark with his brown and yellow coat, and
black velvet collar. The thrush sings in a bush. The catbird, in the
shade, cheers his mate with a rich, mellow note, and then darts out
into the sunshine in his glossy drab dress.
But in late autumn, or in winter, you walk abroad, and where are all
the birds? A crow may sit, scolding, on a dead limb. A social robin
may flit down to your door. The velvet sparrows may be balls of
noise and feathers. But where are the other birds? Are they all
dead?
Oh, no! They have flown off to sunny lands, where they will have
mild weather, and food in plenty, and green trees. The birds migrate.
What is it to migrate? It is to go from one place to another a long way
off. They migrate as the season changes.
Let us take that pretty bird, the bobolink, as an example of a bird on
his travels. In the winter months he is feasting and singing in the
warm West India Islands. There he finds grubs, insects, and seeds in
plenty. He grows so fat, that they call him the butter-bird.
About the first of April, he finds Jamaica too hot for him, and flies
over to Georgia, or South Carolina. He settles in the rice-fields, and
ROBERT O’ LINCOLN.

eats so much rice that he is a great trouble to the planters. They call
him the rice-bird. But they are soon rid of him. About the middle of
May, the rice-bird, with hundreds of his relations, goes up to Virginia
and Pennsylvania.
At this time, he eats May-flies, caterpillars, and various insects. But
his taste for seeds continues, and he devours the young wheat and
barley at a great rate. The farmers name him the reed-bird. Many
reed-birds are shot, and sent to market.
In spite of the guns, the bobolink seems now in the gayest hour of
his life. He sings with all his might, and his black and white coat, with
its touches of yellow, is at its best.
But again he starts northward. He goes up to New York, and New
England, and appears in the orchards and wheat-fields, at the end of
May, or the first of June. There he is called, from his song, the
bobolink.
But Mr. and Mrs. Bobolink must now set themselves to the serious
business of making a nest, and rearing a family. They choose a good
nest place, and begin to build in a great hurry. Mrs. Bobolink is not
so gayly dressed as her mate. She is brown, with a little dull yellow
in her plumage.
Mr. Bobolink ends his wildest songs when the little birds come from
the shells. Their mouths are always wide open, crying for food. Mr.
Bobolink is very busy feeding his children. He flies back and forth all
day long, bringing insects to his nursery. The gay concerts are
ended.
At this time, too, Mr. Bobolink changes his clothes. He puts on a
working suit, with more brown in it. His gay plumes do not come
back until the next spring.
After the little ones learn to fly, in August, if it is hot, the whole family
may go to Canada, for a trip. But as soon as the cool September
mornings come, all the bobolinks think of the South. They gather in
great companies, and turn their heads toward the West Indies.
Now and then, they may rest for a few hours, or a warm day or so,
but they fly pretty steadily southward. When cold weather has come,
we see no more bobolinks. They are all busy eating and singing in
the sunny tropic lands.
I wish you would all read, and perhaps learn to recite a charming
poem called “Robert o’ Lincoln.” It was written, by the great poet
Bryant, about this little bird of many names, and many homes.
Now from the story of the bobolink, you see the manner of this
migration of birds. You see why birds migrate. It is to keep where
they find the food and the weather which they prefer. Its cause is the
change of the season. As the season changes the food changes.
Some birds move away because it is growing too hot where they are,
and they like cooler places. Again, there are birds which stay near us
in the winter, and fly North in the summer, almost to the land of
constant snow.
Those birds which breed in the cold polar regions often find a winter
home in the Northern States. But some birds which breed in the
coldest climates fly to hot countries for their winter of rest and play.
When birds come in the spring, and leave in the fall, they rear their
young where they make their summer home. We call them our
summer birds.
Our winter birds are those which come to us in the cold weather, do
not build nests near us, but fly away when the season grows warm.
While they stay near us, they take shelter at night in shrubs or
evergreen trees.
What we call birds of passage are birds that stop with us for only a
few days, as they are flying long distances, half round the world,
perhaps.
Then there are birds, as the robin, sparrow, thrush, which may stay
all the year round near one place. In the warm weather they build
nests, and rear their young. In cold weather, such birds are often
driven near houses and barns to get food.
Crows may stay all winter in one place if food is plenty. If they cannot
find enough to eat, they gather in great numbers, and fly to places
where they will get more food.
When I was a child, I read that swallows, cuckoos, corn-crakes, and
other birds, would lie torpid all winter. The book I read told me that
the birds would cluster in great masses, silent, nearly frozen, eating
nothing, and in the spring would wake up fresh and gay. That is not
at all true. They do not lie torpid. They fly away.
Birds gather in great numbers, with much noise and flurry, to get
ready for a trip. Crows, storks, cranes, swallows, and others, fly in
great flocks. By the sea-side you may hear a far-off cry and a rush of
wings, and looking up, you may see a flock of wild geese, or ducks,
on their journey, flying far out over the water.
When a vast flock moves in this way, they seem to have some few
wise old birds for guides, in advance, and some for guards on each
side of the band. Geese fly in a V-shaped line, for hours at a time.
When they need to stop for food, they break the V line and fly in
disorder. They seem to search the ground for a feeding place. A
cornfield suits them best, and they settle for a feast. If they cannot
find a cornfield they will try a swamp.
Hawks travel over half the world. The hawk, which summers on the
Scotch hills, may go to Egypt for winter, and perch on the pyramids.
The stork, which the little Dutch children in Holland feed and love,
may go to Africa for Christmas. The birds which you feed in July will
be singing in Hayti or Brazil in January.
What is very strange is, that birds will, year after year, come back to
the very place and nest that they left. The oriole, catbird, bluebird,
jay, titmouse, and others, will each summer return to the same vine
or tree, to build a new nest or repair the old one.
They come singing back, and we are glad to see them. But from their
songs we get no news of the fair tropic lands where they have been
happy amid rich fruits and flowers.
LESSON XXXII.
NEST BUILDING.
I think nothing about birds is more interesting than their way of
building their nests. In this lesson we will look at a few curious nest-
builders.
First, let me tell you that that largest of birds, the ostrich, builds no
nest. She puts her eggs in the sand. The sun-heat is all they need
during the day, and the father-bird cares for them at night. A few
birds lay their eggs in heaps of dead leaves, and let the leaves keep
them warm.
The cuckoo,[26] and the cow-bird[27] lay their eggs in the nest of
some other bird. They choose a bird smaller than themselves, and
put one egg in its nest. Then they go to another nest, and so on, until
their eggs are laid.
A few birds lay their eggs right on the earth, or sand, and make no
nest at all. But they sit on the eggs, and brood them. Most birds
make nice, careful nests. They seem to take pride in building good
homes.
A lady who has carefully studied the ways of birds, says that all birds
of a kind do not build equally good nests. For instance, some robins
build very strong, neat nests. Others build loose, untidy nests, which
will hardly hold the eggs.
This same lady says that birds, by practice, improve in nest building.
As a rule, she thinks the old birds, that have built for several years,
make better nests than robins building for their first brood. She says
she watched a robin, which had a home in her garden. That robin
improved in nest building, and built better and better each year.
Perhaps no bird builds a more firm, neat, and elegant nest, than that
ON THE TREE TOP.

smallest of all,—the humming-bird. This bird does not need a large


nest, she is so tiny, and her eggs, usually only two, are like small
beans. The nest is made in the shape of a cup. It is built of soft
moss, or the downy seeds of plants. These are pressed and
moulded until they are almost like felt.
The nest is made quite thick. All over the outside, the bird fastens
bits of moss, or lichens. These are stuck on with a kind of glue, from
the bird’s mouth. This is done, not so much for beauty, as to conceal
the nest. When thus pasted over with moss, it looks like a knot or bit
of tree branch.
This tiny bird is very shy, and wishes to hide its nest. It is so
cunningly built, that even when close by it you are little likely to see
it.
The bird does not fly straight to, or from, this nest. That might lead
enemies there. Instead, it rises high, straight up into the air, and
when up out of sight, takes its direction as it chooses. When it comes
back, it pursues a similar plan. From far up in the air, above the nest,
it drops straight down, like a little fiery star, into its home.
The goldfinch is another bird which glues mosses on the outside of
its nest to hide it. While this is done rather for use than beauty, I think
most birds like to have a pretty home. I have seen birds weave bits
of colored wool, or silk, in and out the nest, plainly for the sake of the
color, and not for strength.
All the finch family line their nest with down or feathers. The wood-
wren, on the contrary, lines its nest always with hair, and never with
feathers. She goes far and wide to find soft hairs for this use.
I think an oriole’s nest is one of the most beautiful of bird-homes.
The mother-oriole makes the nest, and her mate brings her wool,
fine root-fibres, hairs and threads, which she uses. If he brings her a
bit which she does not like, she throws it away, and seems to think
him a bird of very little sense.
If Mrs. Oriole is not suited with her work, as it goes on, she tears it
down, and goes to work again. She wants it just right.
The nest is in the shape of a long pocket, and is sewed firmly to
some twigs on the end of a branch. It is very curious to see the
stitches which are taken in and out, with string, or long horse-hairs.
The nest is tied firmly to the tree, and is woven very firmly together. It
is lined with downy seeds. The entrance is small and near the top,
and the nest is larger at the bottom, where the young birds will lie.
The tailor-bird sews even better than the oriole. She takes a large
leaf, bends the edges against those of a leaf near, and carefully
sews them together, with bits of fibre for thread, while her bill is the
needle. When this leaf-purse is made, the cunning little mother fills it
half full of cotton-like down, from plants, and her home is made.
Sometimes she chooses a large leaf, and sews its edges together.
The object of these nests is to have them hung far out, where
snakes cannot get at the eggs or young. For you must know that
snakes are cruel enemies of birds.
The house-sparrow likes to build her nest under overhanging eaves.
If she builds where she has not a roof of that kind, she makes a roof
for herself, of straw.
Many birds, as the woodpecker, titmouse, and others, find a hole in a
tree, and put in a soft lining. This makes a very nice, safe home.
The golden-crested wren makes a most lovely nest of mosses,
woven firmly together with spiders’ webs and cobwebs. It is very
delicate and pretty.
Just the opposite of this is a magpie’s nest. That is a large platform
of coarse twigs, and over it a roof, quite as large, of twigs, while all
around it the magpie sets up a thorn fence. You would hardly think a
bird could build such a house.
Once I found the nest of the song thrush. It was large, and made of
grass, straw, and such things, all firmly plastered with mud. It was
nearly as smooth inside as a china bowl. I wondered that this little
bird could build such a large, heavy nest.
Many birds which live near the water build their nests among the tall
reeds. They will bind three or four reeds together, with the nest hung
between them.
No doubt you have often found the neat little round nest of the
bluebirds, or yellow-birds, nicely woven of hairs, and made smooth
and soft inside. Sometimes their soft, smooth nests are woven of
fine, soft fibres. It is wonderful how fine and clean they are, after the
little busy bird has made them ready for her home.
Many birds build in clefts of rocks, or under large overhanging stones
by the water-side. Their chief thought seems to be, to have the nest
safely hidden. Other birds build right on the ground. Have you never
found a lark’s nest, low among daisies, grass and buttercups?
Last summer I found two nests of the meadow pipit, or peewee.
They were built of dry grass in a hollow, shaded by some bramble-
berry bushes and big dandelions. I had one of these nests drawn for
the cover of this Reader. It was a very pretty bower, and the little
birds grew up safely.
Most birds build each one alone, but in Africa the weaver-bird lives in
colonies. The nests are built like very large wasps’ nests. Sometimes
one or two hundred birds will build in one place. They make a roof
for the nest.
I began by telling you of very little nests. I will end by telling you of a
very big nest. I saw the nest of a fishing eagle, in a great pine-tree.
The nest was built of large sticks. It was nearly as large as a half
barrel. The tree was dead. A tree always dies when an eagle builds
in it. This nest was more like a great rough platform than a nest. It
had a wall of sticks about it to keep the little eaglets from falling out
before their feathers grew.

FOOTNOTES:
[26] The cuckoo in England lays in the nests of other birds. The
American cuckoo does not.
[27] The cow-bird is also called the cow-bunting.
LESSON XXXIII.
THE BIRD AT HOME.
You have now seen the bird building a nest, and you have seen the
finished nest. Let us take a little look at the bird at home. Let us have
a peep at the family life of birds.
The mother-bird lays two, four, six, or more eggs in her nest. Each
kind of bird has its own kind of eggs. The wood-pigeon has a pure
white egg; the blackbird’s egg is a bluish green, with russet spots;
the cuckoo’s egg is of a yellowish tint with red and brown marks; the
kingfisher’s egg is yellow with orange spots; the robin’s egg is a
lovely greenish blue. Some eggs have purple spots, some are brown
with red spots.
Each bird knows its own eggs. Sometimes a lazy cow-bird puts her
eggs in the nest of a wren or bluebird, while that bird is away looking
for food. When the bird comes home, she knows at once the strange
egg in her nest. She scolds and cries. But, in the end, she takes care
of it.
When eggs are put into a nest in this way, it is the strange egg which
thrives. The cow-bird hatches before the eggs among which it lies.
Then the mother-bird at once begins to feed her adopted child, and
her own eggs are left and do not hatch.
The young cuckoo is so big and strong that it pushes its foster
brothers and sisters out of the nest, and lives there alone. The good
mother-bird, perhaps only a little sparrow, tires herself out bringing
insects for the wide-open beak of her big, greedy child.
The mother-bird is very patient all the long days, or weeks, while she
must sit brooding her eggs. If you go near her, she may fly off, or she
may cower close over her eggs, and look at you in a very timid way. I
am sure you will hurry past, and not terrify the dear little thing.
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