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

Core Data by Tutorials iOS 8 and Swift Edition Aaron Douglas - Download the ebook and start exploring right away

The document promotes the ebook 'Core Data by Tutorials iOS 8 and Swift Edition' by Aaron Douglas and provides links to download it along with other recommended iOS development ebooks. It outlines the contents of the book, including chapters on Core Data fundamentals, intermediate fetching, syncing with iCloud, and performance optimization. The book is intended for iOS developers familiar with Swift who want to learn about Core Data.

Uploaded by

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

Core Data by Tutorials iOS 8 and Swift Edition Aaron Douglas - Download the ebook and start exploring right away

The document promotes the ebook 'Core Data by Tutorials iOS 8 and Swift Edition' by Aaron Douglas and provides links to download it along with other recommended iOS development ebooks. It outlines the contents of the book, including chapters on Core Data fundamentals, intermediate fetching, syncing with iCloud, and performance optimization. The book is intended for iOS developers familiar with Swift who want to learn about Core Data.

Uploaded by

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

Visit ebookfinal.

com to download the full version and


explore more ebooks or textbooks

Core Data by Tutorials iOS 8 and Swift Edition


Aaron Douglas

_____ Click the link below to download _____


https://ebookfinal.com/download/core-data-by-tutorials-
ios-8-and-swift-edition-aaron-douglas/

Explore and download more ebooks or textbook at ebookfinal.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Core Data in Swift Data Storage and Management for iOS and
OS X Marcus S. Zarra

https://ebookfinal.com/download/core-data-in-swift-data-storage-and-
management-for-ios-and-os-x-marcus-s-zarra/

iOS 8 Swift Programming Cookbook Solutions Examples for


iOS Apps 1st Edition Nahavandipoor

https://ebookfinal.com/download/ios-8-swift-programming-cookbook-
solutions-examples-for-ios-apps-1st-edition-nahavandipoor/

iOS 5 by Tutorials Volumes 1 and 2 2nd Edition Ray


Wenderlich

https://ebookfinal.com/download/ios-5-by-tutorials-
volumes-1-and-2-2nd-edition-ray-wenderlich/

Core Data Data Storage and Management for iOS OS X and


iCloud Second Edition Marcus S. Zarra

https://ebookfinal.com/download/core-data-data-storage-and-management-
for-ios-os-x-and-icloud-second-edition-marcus-s-zarra/
Introducing iOS 8 1st Edition Steve Derico

https://ebookfinal.com/download/introducing-ios-8-1st-edition-steve-
derico/

Learning iOS UI Development Implement complex iOS user


interfaces with ease using Swift 1st Edition D'Areglia

https://ebookfinal.com/download/learning-ios-ui-development-implement-
complex-ios-user-interfaces-with-ease-using-swift-1st-edition-
dareglia/

Swift Data Structure and Algorithms 1st Edition Azar

https://ebookfinal.com/download/swift-data-structure-and-
algorithms-1st-edition-azar/

Test Driven IOS Development with Swift 4 Third Edition


Dominik Hauser

https://ebookfinal.com/download/test-driven-ios-development-with-
swift-4-third-edition-dominik-hauser/

Learning Swift Building Apps for macOS iOS and Beyond 3rd
Edition Jonathon Manning

https://ebookfinal.com/download/learning-swift-building-apps-for-
macos-ios-and-beyond-3rd-edition-jonathon-manning/
Core Data by Tutorials iOS 8 and Swift Edition Aaron
Douglas Digital Instant Download
Author(s): Aaron Douglas, Saul Mora, Matthew Morey, Pietro Rea
ISBN(s): 9780989675192, 098967519X
File Details: PDF, 17.11 MB
Year: 2014
Language: english
Core Data by Tutorials
By the raywenderlich.com Tutorial Team

Aaron Douglas, Saul Mora,

Matthew Morey, and Pietro Rea

Copyright © 2013 Razeware LLC.

All rights reserved. No part of this book or corresponding materials (such as


text, images, or source code) may be reproduced or distributed by any means
without prior written per- mission of the copyright owner.

This book and all corresponding materials (such as source code) are provided
on an "as is" basis, without warranty of any kind, express or implied, including
but not limited to the warranties of merchantability, fitness for a particular
purpose, and noninfringement. In no event shall the authors or copyright
holders be liable for any claim, damages or other liability, whether in action of
contract, tort or otherwise, arising from, out of or in connec- tion with the
software or the use or other dealings in the software.

All trademarks and registered trademarks appearing in this book are the
property of their respective owners.
Table of Contents: Overview
Introduction .............................................................................................. 9!
Chapter 1: Your First Core Data App ............................................. 15!
Chapter 2: NSManagedObject Subclasses .................................... 33!
Chapter 3: The Core Data Stack ...................................................... 58!
Chapter 4: Intermediate Fetching .................................................... 79!
Chapter 5: NSFetchedResultsController ........................................ 111!
Chapter 6: Versioning and Migration ........................................... 134!
Chapter 7: Syncing with iCloud ...................................................... 170!
Chapter 8: Unit Testing..................................................................... 188!
Chapter 9: Measuring and Boosting Performance...................... 204!
Chapter 10: Multiple Managed Object Contexts ....................... 236!
Conclusion ............................................................................................ 256!
Table of Contents: Extended
Introduction .............................................................................................. 9!
What you need ............................................................................................. 10!
Who this book is for ..................................................................................... 10!
How to use this book..................................................................................... 11!
What’s in store ............................................................................................... 11!
Source code and forums .............................................................................. 12!
Updates........................................................................................................... 12!
License ............................................................................................................. 13!
About the authors .......................................................................................... 13!
About the editors ........................................................................................... 14!
Chapter 1: Your First Core Data App ............................................. 15!
Getting started .............................................................................................. 15!
Modeling your data ..................................................................................... 23!
Saving to Core Data .................................................................................... 26!
Fetching from Core Data ............................................................................. 30!
Where to go from here? .............................................................................. 32!
Chapter 2: NSManagedObject Subclasses .................................... 33!
Getting started .............................................................................................. 33!
Modeling your data ..................................................................................... 36!
Storing non-standard data types in Core Data ...................................... 39!
Managed object subclasses ........................................................................ 40!
Propagating a managed context .............................................................. 44!
Data validation in Core Data ..................................................................... 53!
Tying everything up ...................................................................................... 56!
Where to go from here? .............................................................................. 57!
Chapter 3: The Core Data Stack ...................................................... 58!
Getting started .............................................................................................. 58!
The managed object model ........................................................................ 60!
The persistent store ....................................................................................... 60!
The persistent store coordinator ................................................................. 61!
The managed object context ...................................................................... 61!
Creating your stack object .......................................................................... 62!
Modeling your data ..................................................................................... 66!
Adding managed object subclasses .......................................................... 70!
A walk down persistence lane .................................................................... 71!
Deleting objects from Core Data ............................................................... 76!
Where to go from here? .............................................................................. 78!
Chapter 4: Intermediate Fetching .................................................... 79!
NSFetchRequest: the star of the show ....................................................... 79!
Introducing the Bubble Tea app................................................................. 80!
Stored fetch requests.................................................................................... 82!
Fetching different result types .................................................................... 87!
Sorting fetched results ................................................................................ 103!
Asynchronous fetching ................................................................................ 105!
Batch updates: no fetching required ....................................................... 108!
Where to go from here? ............................................................................ 110!
Chapter 5: NSFetchedResultsController ........................................ 111!
Introducing the World Cup app ............................................................... 111!
It all begins with a fetch request... ........................................................... 113!
Grouping results into sections.................................................................... 119!
“Cache” the ball .......................................................................................... 123!
Monitoring changes ..................................................................................... 124!
Inserting an underdog ................................................................................ 129!
Where to go from here? ............................................................................ 133!
Chapter 6: Versioning and Migration ........................................... 134!
When to migrate ......................................................................................... 134!
The migration process................................................................................. 135!
Getting started ............................................................................................ 136!
A lightweight migration .............................................................................. 137!
A manual migration .................................................................................... 146!
A complex mapping model ....................................................................... 153!
Migrating non-sequential versions ........................................................... 159!
Where to go from here? ............................................................................ 169!
Chapter 7: Syncing with iCloud ...................................................... 170!
Getting started ............................................................................................ 171!
CloudNotes ................................................................................................... 172!
Enabling iCloud ........................................................................................... 173!
The cloud stack ............................................................................................ 175!
Testing iCloud .............................................................................................. 176!
Responding to iCloud changes.................................................................. 182!
Switching iCloud accounts .......................................................................... 184!
Where to go from here? ............................................................................ 187!
Chapter 8: Unit Testing..................................................................... 188!
Getting started ............................................................................................ 189!
Core Data stack for testing ....................................................................... 190!
Your first test ................................................................................................ 191!
Asynchronous tests ....................................................................................... 194!
Tests first ....................................................................................................... 196!
Validation and refactoring ....................................................................... 200!
Where to go from here? ............................................................................ 203!
Chapter 9: Measuring and Boosting Performance...................... 204!
Getting started ............................................................................................ 204!
Measure, change, verify ............................................................................ 207!
Fetching and performance ........................................................................ 217!
Where to go from here? ............................................................................ 235!
Chapter 10: Multiple Managed Object Contexts ....................... 236!
Getting started ............................................................................................ 236!
Doing work in the background ................................................................. 242!
Editing on a scratchpad ............................................................................. 248!
Where to go from here? ............................................................................ 254!
Conclusion ............................................................................................ 256!
Dedications
“To my partner, Mike, who supports all of the weirdness that is me.”

–Aaron Douglas

“To my Wife – without your tireless support behind the scenes, all my
work the world enjoys would not be possible.”

–Saul Mora

“To my amazing wife Tricia and my parents - Thanks for always


supporting me.”

–Matthew Morey

“To my Core Data mentors Otto, Ron, Ahmed and Siva.”

–Pietro Rea
Introduction
By Greg Heo

What is Core Data? You'll hear a variety of answers to this question: It’s a
database! It's SQLite! It's not a database! And so forth.

Here's the technical answer: Core Data is an object graph management and
persistence framework in the OS X and iOS SDKs.

That means Core Data can store and retrieve data, but it is not a relational
database like MySQL or SQLite. Although it can use SQLite as the data store behind
the scenes, you don’t think about Core Data in terms of tables and rows and
primary keys.

Imagine you’re writing an app to keep track of dining habits. You have a varied set
of objects: restaurant objects, each with properties such as name and address;
categories, to organize the restaurants; and visits, to log each visit to a restaurant.
The object graph in memory might look something like this:

Object graph management means Core Data works with objects that you define,
such as the ones in the diagram above. For example, each restaurant (represented
by a red bubble) would have a property pointing back to the category object. It
would also have a property holding the list of visits.

raywenderlich.com Page 9
Core Data by Tutorials Introduction

Since Cocoa is an object-oriented framework, you’re probably storing data in


objects already. Core Data builds on this to keep track of the objects and their
relationships to each other. You can imagine expanding the graph to include what
the user ordered, ratings and so on.

Persistence means the data is stored somewhere durable such as the device’s
flash memory or “the cloud.” You point to the entire graph and just say “save.”
When your app launches, you just say “load” and the entire object graph pops up in
memory again, ready for use. That’s Core Data at work!

Maybe your users eat out a lot and have thousands of restaurant visits—rest
assured Core Data is smart about lazily loading objects and caching to optimize
both memory usage and speed.

Core Data has many other features aside from simply storing and fetching data:
You can perform custom filtering with predicates, sort the data and synchronize a
data store with iCloud, among other things. You’ll learn all about these features and
more in this book.

What you need


To follow along with the tutorials in this book, you’ll need the following:
• A Mac running OS X Mavericks (10.9.5) or later. You’ll need this to be able to
install the latest version of Xcode.
• Xcode 6.0.1 or later. Xcode is the main development tool for iOS. You can
download the latest version of Xcode for free from the Mac app store here:
https://itunes.apple.com/app/xcode/id497799835?mt=12
• One or more devices (iPhone, iPad or iPod Touch) running iOS 8 or later,
and a paid membership to the iOS development program [optional]. You’ll
only need a paid membership and a physical iOS device for Chapter 7, “Syncing
with iCloud.” For the rest of the book, you can get by with the iOS 8 Simulator
that comes with Xcode.
Once you have these items in place, you’ll be able to follow along with every
chapter in this book.

Who this book is for


This book is for iOS developers who already know the basics of iOS and Swift, and
want to learn Core Data.

If you’re a complete beginner to iOS, we suggest you read through The iOS
Apprentice, 3rd Edition first. That will give you a solid foundation in building iOS
apps from the ground-up.

raywenderlich.com Page 10
Core Data by Tutorials Introduction

If you know the basics of iOS development but are new to Swift, we suggest you
read Swift by Tutorials first. That book has a similar hands-on approach and takes
you on a comprehensive tour through the Swift language.

You can find both of these prerequisite books at our store:


http://www.raywenderlich.com/store

How to use this book


This book will teach you the fundamentals of Core Data by means of hands-on
tutorials. You’ll jump right into building a Core Data app in Chapter 1, as we think
most people learn best by doing. We encourage you to type along with the
instructions in the book.

If you’re new to Core Data or want to review the basics, we suggest you start with
Chapters 1–3. These chapters cover the fundamentals of Core Data and you’ll need
the knowledge in them to understand the rest of the book.

Otherwise, we suggest a pragmatic approach. Each chapter stands on its own, so


you can pick and choose the chapters that interest you the most.

What’s in store
Here’s a quick summary of what you’ll find in each chapter:
1. Chapter 1, Your First Core Data App: You’ll click File\New Project and write
a Core Data app from scratch! This chapter covers the basics of setting up your
data model and then adding and fetching records.
2. Chapter 2, NSManagedObject Subclasses: NSManagedObject is the base data
storage class of your Core Data object graphs. This chapter will teach you how
you customize your own managed object subclasses to store and validate data.
3. Chapter 3, The Core Data Stack: Under the hood, Core Data is made up of
many parts working together. In this chapter, you’ll learn about how these parts
fit together, and move away from the starter Xcode template to build your own
customizable system.
4. Chapter 4, Intermediate Fetching: Your apps will fetch data all the time, and
Core Data offers many options for getting the data to you efficiently. This chapter
covers more advanced fetch requests, predicates, sorting and asynchronous
fetching.
5. Chapter 5, NSFetchedResultsController: Table views are at the core of many
iOS apps, and Apple wants to make Core Data play nicely with them! In this
chapter, you’ll learn how NSFetchedResultsController can save you time and code
when your table views are backed by data from Core Data.

raywenderlich.com Page 11
Core Data by Tutorials Introduction

6. Chapter 6, Versioning and Migration: As you update and enhance your app,
its data model will almost certainly need to change. In this chapter, you’ll learn
how to create multiple versions of your data model and then migrate your users
forward so they can keep their existing data as they upgrade.
7. Chapter 7, Syncing with iCloud: Move beyond storing data locally on a single
device, to cloud storage and synchronizing across all the user’s devices. This
chapter covers how to extend an existing Core Data app to use iCloud.
8. Chapter 8, Unit Tests: Testing is an important part of the development
process, and you shouldn’t leave Core Data out of those tests! In this chapter,
you’ll learn how to set up a separate test environment for Core Data and see
examples of how to test your models.
9. Chapter 9, Measuring and Boosting Performance: No one ever complained
that an app was too fast, so it’s important to be vigilant about tracking
performance. In this chapter, you’ll learn how to measure your app’s performance
with various Xcode tools and then pick up some tips for dealing with slow spots in
your code.
10. Chapter 10, Multiple Managed Object Contexts: In this final chapter, you’ll
expand the usual Core Data stack to include multiple managed object contexts.
You’ll learn how this can improve perceived performance and help make your app
architecture less monolithic and more compartmentalized.

Source code and forums


This book comes with complete source code for each of the chapters—it’s shipped
with the PDF. Some of the chapters also include starter projects or other required
resources, and you’ll definitely want to have these on hand as you go through the
book.

We’ve set up an official forum for the book at


http://www.raywenderlich.com/forums. This is a great place to ask questions you
have about the book or about developing Core Data apps, or to submit any errors
or suggested updates.

Updates
Since you’ve purchased the PDF version of this book, you get free access to any
updates we make to the book!

The best way to get update notifications is to sign up for our monthly newsletter.
This includes a list of the tutorials that came out on raywenderlich.com that month,
any important news like book updates or new books, and a list of our favorite
development links for that month. You can sign up at this URL:

http://www.raywenderlich.com/newsletter

raywenderlich.com Page 12
Core Data by Tutorials Introduction

License
By purchasing Core Data by Tutorials, you have the following license:
• You are allowed to use and/or modify the source code in Core Data by Tutorials in
as many apps as you want, with no attribution required.
• You are allowed to use and/or modify all art, images and designs that are included
in Core Data by Tutorials in as many apps as you want, but must include this
attribution line somewhere inside your app: “Artwork/images/designs: from Core
Data by Tutorials book, available at http://www.raywenderlich.com.”
• The source code included in Core Data by Tutorials is for your personal use only.
You are NOT allowed to distribute or sell the source code in Core Data by
Tutorials without prior authorization.
• This book is for your personal use only. You are NOT allowed to sell this book
without prior authorization or distribute it to friends, co-workers or students; they
would need to purchase their own copies.
All materials provided with this book are provided on an “as is” basis, without
warranty of any kind, express or implied, including but not limited to the warranties
of merchantability, fitness for a particular purpose and non-infringement. In no
event shall the authors or copyright holders be liable for any claim, damages or
other liability, whether in an action of contract, tort or otherwise, arising from, out
of or in connection with the software or the use or other dealings in the software.

All trademarks and registered trademarks appearing in this book are the property of
their respective owners.

About the authors


Pietro Rea is an iOS developer based in Hoboken, NJ.
He started writing code in high school and currently
specializes in Objective-C, Swift and iOS. These days, he
develops mobile applications for Quidsi, an Amazon
company. You can follow him on Twitter as @pietrorea or
on his blog at www.pietrorea.com

Saul Mora is an engineer at Coursera, in Mountain View,


California. He enjoys writing apps, riding bicycles and
traveling the world. Saul is a frequent speaker at many
iOS and Mac developer conferences and also produces a
podcast for developers called NSBrief (nsbrief.com).
Occasionally, you can find Saul teaching the wonders of
programming to the next generation of developers.

raywenderlich.com Page 13
Core Data by Tutorials Introduction

Aaron Douglas was that kid taking apart the home


appliances at five years of age to see how they worked.
Today he's a full-time iOS developer with a passion for
doing things right the first time. He enjoys camping
during the summer and pretending to be a storm chaser
while sitting at home. Find him on the Interwebs as
@astralbodies.

Matthew Morey is an engineer, developer, hacker,


creator, and tinkerer. As an active member of the iOS
community and a Lead Developer at ChaiOne he has led
numerous successful mobile projects worldwide.

When not developing apps he enjoys traveling,


snowboarding, and surfing. He blogs about technology
and business at matthewmorey.com.

About the editors


Richard Turton was the technical editor for this book. He
is an iOS developer for a leading UK mobile agency, a
prolific Stack Overflow participant and the author of a
development blog, commandshift.co.uk. When he's not in
front of a computer, he is underneath one or both of his
daughters as a horse, monkey or cushion.

Bradley C. Phillips was the editor for this book, and was
the first editor to come aboard at raywenderlich.com. He
has worked as a journalist and previously directed the
intelligence department of an investigative firm in New
York City. Right now, Bradley works freelance and pursues
his own projects. Contact him if you need a skilled and
experienced editor for your blog, books or anything else.

Greg Heo was the final pass editor for this book, and has
been part of the editorial team at raywenderlich.com since
2012.

He has been nerding out with computers since the


Commodore 64 era in the 80s and continues to this day on
the web and on iOS. He likes caffeine, codes with two-
space tabs and writes with semicolons.

raywenderlich.com Page 14
Chapter 1: Your First Core
Data App
By Pietro Rea

Welcome to Core Data! In this chapter, you’ll write your very first Core Data app.
You’ll see how easy it is to get started with all the resources provided in Xcode,
from the starter code templates to the data model editor.

You’re going to hit the ground running right from the first chapter in this book; by
the end of the chapter you’ll know how to:
• model data you want to store in Core Data using Xcode’s model editor;
• add new records to Core Data;
• fetch a set of records from Core Data; and
• display the fetched results to the user in a table view.
You’ll also get a sense of what Core Data is doing behind the scenes, and how you
can interact with the various moving pieces there. This will put you well on your
way to understanding the next two chapters, which continue the introduction to
Core Data with more advanced models and data validation, amongst other things.

We’re getting ahead of ourselves though – it’s time to build an app!

Getting started
Open Xcode and create a new iPhone project based on the Single View
Application template. Call the app HitList and make sure Use Core Data is
checked:

raywenderlich.com Page 15
Core Data by Tutorials Chapter 1: Your First Core Data App

Checking the Use Core Data box will cause Xcode to generate boilerplate code for
what’s known as a Core Data stack in AppDelegate.swift.

The Core Data stack consists of a set of objects that facilitate saving and retrieving
information from Core Data. There’s an object to manage the Core Data state as a
whole, an object representing the data model, and so on.

You’ll learn about each of these pieces in these first few chapters. Later, you’ll even
have the chance to write your own Core Data stack! The standard stack works just
fine for many apps but based on your app and its data, you can customize the stack
to be more efficient.

Note: Not all Xcode templates have the option to start with Core Data. In
Xcode 6, only the Master-Detail Application and the Single View
Application templates have the Use Core Data checkbox.

The idea for this sample app is simple. There will be a table view with a list of
names for your very own “hit list”. You’ll be able to add names to this list and
eventually, you’ll use Core Data to make sure the data is stored between sessions.
We don’t condone violence in this book so you can think of this app as a “favorites
list” to keep track of your friends too, of course! ;]

Click on Main.storyboard to open it in Interface Builder. Select its only view


controller and change its size class to Regular Height and Compact Width to match
an iPhone in portrait mode:

raywenderlich.com Page 16
Core Data by Tutorials Chapter 1: Your First Core Data App

Next, embed the view controller in a navigation controller. From Xcode’s Editor
menu, select Embed In…\ Navigation Controller.

Back in Interface Builder, drag a Table View from the object library into the view
controller so that it covers the entire view.

Then, drag a Bar Button Item and place it on the view controller’s newly added
navigation bar. Finally, double-click the bar button item to change its text to Add.
Your canvas should now look like the following screenshot:

Every time you tap Add on the top-right, an alert containing a text field will appear
on the screen. From there you’ll be able to type someone’s name into the text field.
Dismissing the alert will save the name and refresh the table view with all the
names you’ve saved up to that point.

raywenderlich.com Page 17
Core Data by Tutorials Chapter 1: Your First Core Data App

Before you can do that, you need to make the view controller the table view’s data
source. Ctrl-drag from the table view to the yellow view controller icon above the
navigation bar, as shown below, and click on dataSource:

In case you were wondering, you don’t need to set up the table view’s delegate
since tapping on the cells won’t trigger any action. It doesn’t get simpler than this!

Open the Assistant Editor by hitting Command-Option-Enter or by selecting the


middle button on the Editor toolset on the Xcode bar. Ctrl-drag from the table view
onto ViewController.swift, inside the class definition to insert an outlet:

Name the new IBOutlet property tableView, resulting in the following line:

@IBOutlet weak var tableView: UITableView!

Ctrl-drag from the Add bar button item onto ViewController.swift, but this time,
create an action instead of an outlet and name the method addName:

@IBAction func addName(sender: AnyObject) {

You can now refer to the table view and the bar button item’s action in code. Next,
set up the model for the table view. Add the following property to
ViewController.swift:

//Insert below the tableView IBOutlet


var names = [String]()

names is a mutable Array to hold the strings for the table view to display.

raywenderlich.com Page 18
Core Data by Tutorials Chapter 1: Your First Core Data App

Replace the implementation of viewDidLoad with the following:

override func viewDidLoad() {


super.viewDidLoad()
title = "\"The List\""
tableView.registerClass(UITableViewCell.self,
forCellReuseIdentifier: "Cell")
}

This will set a title and register the UITableViewCell class with the table view. You
do this so that when you dequeue a cell, the table view will return a cell of the
correct type.

Still in ViewController.swift, declare that ViewController will conform to the


UITableViewDataSource protocol by editing the class declaration:

//Add UITableViewDataSource to class declaration


class ViewController: UIViewController, UITableViewDataSource {

Immediately, Xcode will complain about ViewController not conforming to the


protocol. Below viewDidLoad, implement the following data source methods to fix
the error:

// MARK: UITableViewDataSource
func tableView(tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return names.count
}

func tableView(tableView: UITableView,


cellForRowAtIndexPath
indexPath: NSIndexPath) -> UITableViewCell {

let cell =
tableView.dequeueReusableCellWithIdentifier("Cell")
as UITableViewCell

cell.textLabel!.text = names[indexPath.row]

return cell
}

If you’ve ever worked with UITableView, this code should look very familiar. The
first method says that the table view will have as many rows as the names array has
strings.

raywenderlich.com Page 19
Core Data by Tutorials Chapter 1: Your First Core Data App

The second method, tableView(_:cellForRowAtIndexPath:), dequeues table view


cells and populates them with the corresponding string in the names array.

Don’t run the app just yet. First, you need a way to input names so the table view
can display them.

Implement the addName IBAction method you Ctrl-dragged into your code earlier:

//Implement the addName IBAction


@IBAction func addName(sender: AnyObject) {

var alert = UIAlertController(title: "New name",


message: "Add a new name",
preferredStyle: .Alert)

let saveAction = UIAlertAction(title: "Save",


style: .Default) { (action: UIAlertAction!) -> Void in

let textField = alert.textFields![0] as UITextField


self.names.append(textField.text)
self.tableView.reloadData()
}

let cancelAction = UIAlertAction(title: "Cancel",


style: .Default) { (action: UIAlertAction!) -> Void in
}

alert.addTextFieldWithConfigurationHandler {
(textField: UITextField!) -> Void in
}

alert.addAction(saveAction)
alert.addAction(cancelAction)

presentViewController(alert,
animated: true,
completion: nil)
}

Every time you tap the Add bar button item, this method presents an
UIAlertController with a text field and two buttons, Save and Cancel.

Save takes whatever text is currently in the text field, inserts it into the name array
and reloads the table view. Since the names array is the model backing the table
view, whatever you typed into the text field will appear in the table view.

Finally it’s time to build and run your app for the first time. Tap the Add bar button
item. The alert controller will look like this:

raywenderlich.com Page 20
Discovering Diverse Content Through
Random Scribd Documents
carrying the rifle with him—not an easy feat by any means even for a
sailor!
It seemed to me that the fierce dog only took a couple of
prodigious bounds, and then sprang deliberately at Ned, utterly
regardless of the deadly sword blade. Like a man-eating tiger, he
evidently relied upon his weight and the suddenness of his attack.
I saw my coxswain aim a blow at the huge brute as it rushed in
upon him; but the next instant I saw him borne backwards to the
ground as the animal closed with him. At the same instant I caught
sight of the gunner raising his rifle to his shoulder as if with the
intention of blowing out the bloodhound’s brains.
It was no longer a dream, but a living tragical reality; and there
was I, safely ensconced in a tree, while my daring shipmates were
fighting for their lives with what was practically a savage wild beast!
Of course I saw now that Ned had unselfishly wished to place us in
safety before confronting the bloodhound single-handed. Recalled to
myself, and anxious to lend any assistance that lay in my power, I
hastily commenced to descend the tree; but as ill-luck would have it,
I grasped a rotten branch, which came away in my hand, and I was
precipitated to the ground—fortunately from no great height. As I fell,
I fancied I heard loud snarling and a deep moan. The next instant I
was on my feet again, feeling rather confused, but having suffered
nothing but one or two bruises. I was immensely relieved by the sight
that met my gaze, which made an impressive tableau.
The bloodhound lay stretched out on the ground, stone-dead, with
a puncture in the region of the heart. Ned was kneeling on the
ground close to the body of his assailant, and holding a gory sword
in his right hand. Leaning upon his rifle, and gazing down at the
defunct beast, stood Mr. Triggs.
“’Tis a good job, Ned,” the latter was saying, “that I didn’t let fly at
the beast. The report of my rifle would have brought a nest of
hornets about our ears, I’m thinking.”
“That it would,” answered my coxswain, wiping his sword in a
tussock of long grass; “but how it is them swabs have got separated
from their dog beats me.”
“Well, it’s the fortune of war,” said the gunner grimly, “and we must
be thankful for it. At the same time, mind you, they may not be a
hundred miles away, and we had better make ourselves scarce, and
steer for the sea-shore with steam up in all boilers.”
Ned sprang to his feet, and after inquiring of me whether I was
hurt by my fall out of the tree, he proposed that we should secrete
the bloodhound’s body for fear it should be discovered by the
pirates.
This was good advice, and we proceeded to act upon it. The dog’s
body was cumbrous and heavy, but by our united exertions we
dragged it to the edge of a neighbouring ravine and cast it down. As
this particular chasm was fringed with bushes and underwood, it
would not have been an easy matter to detect anything lying among
the rocks at the bottom of it.
I told my shipmates that I felt sure that if the other bloodhound was
still at large, it would be certain, sooner or later, to scent out Ned’s
victim.
The latter, we knew, was the pirate chief’s bloodhound, as we had
instantly recognized it by its mutilated ear.
“Flaying alive would be too good for me now if ever I’m nobbled,”
said Ned, as we once more set out at a sharp run; “leastways if that
cut-throat head of the gang knew that I’d settled the hash of his
highly prized bow-wow.”
“How did you manage to kill the brute?” I asked. “It was an awful
sight to see it fly at you, and I thought I saw it knock you over.”
“Well, it just did bowl me over and no mistake, sir, but I fancied
that something better was in store for me than to be popped off by a
furriner’s dog, and so I kept as cool as a cowcumber, and let drive
with the sword just as the beast was on top of me, as it were. My
killing it was a bit of a fluke, there’s no denying that, for I didn’t know
the bearings of his heart in the least.”
“You’ve rid us of our worst foe, Ned,” I said, “and given us a much
better chance of escape.”
“That was in my mind, of course,” said the seaman. “Thinks I to
myself, ‘Here’s that blooming dog close astarn of us, and somehow
got separated from his mate and his owners. What a chance to put
him out of the way on the quiet! Jiggered if I don’t slit his weasand
for him.’ Well, I did something more effectual than that, Mr. Darcy;
and here we are, with a fair start again, and I hopes as how we’ll
stick to it.”
It certainly seemed like a turning-point in our fortunes; for though
we even now heard some occasional shouts, they seemed to be at a
considerable distance, and we could not detect any baying from the
other bloodhound. I do not know whether I mentioned the fact
before, but I had been rather sceptical as to this latter animal being
upon our trail at all—at any rate during the last half-hour.
We still suffered a great deal of discomfort from our wet clothes
and boots, but we ran gamely on, knowing that everything depended
on our speed.
At length, without further misadventure, we emerged from the
jungle, and found ourselves on a rather extensive expanse of
sandhills, beyond which lay the blue sea, still darkened by the dun
volcanic clouds which hung in mid-air.
“Is that a boat?” asked Ned, excitedly.
CHAPTER XXIII.
A RACE FOR LIFE.

I T was a boat of some kind; there could be no doubt about that. A


somewhat large, unwieldy-looking craft she appeared to be, but
apparently there were only a couple of oarsmen on board, who were
slowly propelling her seawards with a species of long paddle. The
ocean was still in a more or less agitated state, which must have
been owing to the seismic disturbances to which the island and its
surrounding waters had so lately been subjected, for the atmosphere
was just as stagnant as it had been all the morning. This motion
made the boat bob about in a strange unnatural manner, as if she
had a trawl down. She was about half a mile from the shore, as near
as we could judge; and besides the two oarsmen there appeared to
be a third person occupying the stern-sheets.
“We must try to signal that craft,” said Mr. Triggs, emphatically; “’tis
our only chance of escape.”
“But suppose those men on board her are pirates,” said Ned; “we
should just be jumping from the frying-pan into the fire.”
I had been gazing intently at the boat all this time. My sight was
naturally very keen, and I felt almost confident that the occupants of
the boat were negroes. I hurriedly communicated my suspicions to
my shipmates.
“I’m jiggered if I don’t think you’re right, sir,” said Ned, slapping his
thigh vigorously, and peering intently at the unwieldy craft. “Now I
wouldn’t mind wagering a plug o’ baccy that those are the niggers
we saw working in the garden of their shanty, and that figure in the
starn-sheets is the old ‘Mother Bunch’ that lost the run of her legs
and went a cropper on her nose.”
“If it is, can we persuade ’em to take us off?” asked the gunner;
“that’s the question. The boat would hold us all; but as the niggers
are probably the slaves of the pirate chief, they might be afraid to
take us on board.”
“And if they did take us on board,” said I, “it might only be to pull
us round to the creek on the other side of the island, and give us up
to their masters, the pirates.”
“Once on board we might overpower ’em,” said Ned, musingly. “I
only wish—”
A musket shot!
We started in alarm. It appeared to come from somewhere
amongst the sandhills on our extreme right. Anxiously we looked for
the puff of smoke, but could detect nothing.
The echoes of the discharge had hardly died away amongst the
hills, when our ears were saluted with a second and exactly similar
report.
No bullets or shot fell near us.
I glanced at the boat to see if any firing was taking place on board.
The oarsmen had ceased rowing, and appeared to be gazing
shorewards; but no tell-tale smoke was wreathing itself above their
heads.
“This is a queer business, and I don’t like the looks of it,” remarked
Ned. “I’d get up a tree and have a squint round, if I wasn’t afraid of
being spotted by Miguel or some lynx-eyed swab of his kidney.”
At this moment I caught sight of some thin vapoury smoke drifting
slowly over the sandhills at a distance of about a mile on our
extreme right, and drew my companions’ attention to it.
We strained our eyes to the utmost, but could detect no human
figures.
“’Tis a signal to the craft yonder, or I’m a Dutchman!” exclaimed
Ned. “They’re not firing at us, that’s sartin.”
We all turned our eyes upon the boat. Her head was slowly
swinging round towards the shore owing to the efforts of the rowers,
who had resumed their oars.
“There’s no doubt about it,” said the gunner, angrily, “and I don’t
vote we remain passive spectators of it. If we don’t manage to get
hold of that boat, by hook or by crook, we may as well throw up the
sponge altogether.”
“I’m game for a shindy with the lubbers!” cried Ned; “and I agree
with you, Mr. Gunner, that it’s about our only chance of getting off
this plaguy island. But we’ll have pretty tidy odds against us, and are
middling short of ammunition. Now, if I had a few rounds of ball-
cartridge in my pocket, I’d play Old Harry with some of the pirates
before they could come to close quarters!”
There was no time to be lost. We had to traverse the sandhills,
which would be heavy ground to run over; but it did not appear to be
more than half a mile or so to the actual shore.
Ned had resumed his rifle and returned the sword to the gunner.
We had taken especial care to keep our pistols dry when wading
down the stream, and they appeared to be in good order and ready
for use if required.
We carefully noted the direction the boat was heading for, and
then set off at our best pace to try to intercept her. It seemed to me a
forlorn hope; but still I could not help agreeing with my companions
that it would be foolish to throw away such a chance, feeble as it
was. Had we chosen to hide away in the jungle instead, we should
have been unearthed to a dead certainty sooner or later; and then
there would have been a nice kettle of fish to fry. My theory with
regard to the invisible persons who had fired the muskets was, that
they were members of the party that had been pursuing us through
the forest, and that they had reached the sandhills by some short
cut, and were anxious to communicate the fact of our escape to the
negroes, in order that the latter might keep a look-out for us and bar
our escape on that side of the island.
This seemed the most plausible explanation of the mysterious
affair.
And if the negroes combined to assist their masters—as there was
every reason to suppose they would—how terribly the odds against
us would be increased, especially if the black fellows were provided
with weapons.
These thoughts passed quickly through my mind as we sped
across the sandhills. There was a very determined look on the
gunner’s face and on Ned’s. They felt, I am sure, that the supreme
crisis was at hand, and that in a few moments a decisive blow would
be struck which would mean to us victory or death.
“Ha!” said my coxswain in a savage tone, “there’s the whole gang
of villains!”
As he spoke I caught sight of a body of men running with great
speed across the sandhills, as if in an effort to intercept us. They
were then about a quarter of a mile distant, and had evidently just
perceived us. As we were both making for the same point on the
beach, it was only natural, of course, that we should converge on
one another.
A terrible yell arose from the pirate ranks—a yell which rang with
vindictive and spiteful malice.
“Ay! shout away, my hearties!” muttered Ned; “it’ll play the doose
with yer wind.”
“We’re ahead of ’em!” cried the gunner, breathlessly. “Now for a
spurt, lads!—Can you keep up, Mr. Darcy?”
“Rather!” I replied. I was terribly excited, and felt no fatigue or
breathlessness. My feet scarcely seemed to touch the ground. It was
a race for life, and I knew it.
Hurriedly I glanced at the boat. She was still some distance from
the shore, and the rowers did not seem to be exerting themselves in
the least.
We had left the sandhills behind us, and were racing across a
broad expanse of tawny, hard sand.
What would the blacks do? That was the torturing question.
The band of pirates were pouring over the sandhills, yelling as
they came and brandishing their weapons with fierce gestures. They
were, however, a hundred yards in the rear and to the right of us.
Every moment I expected them to open fire on us; but I suppose
they were anxious to capture us alive, and I felt sure that we were
caught in a trap—hemmed in between them and their allies the
blacks.
Oh, how slowly that boat came lumbering along over the waves! I
eyed her with astonishment.
We had recognized the chief and Miguel as heading the pursuing
band. There was no mistaking them. Thank God, they had not the
other bloodhound with them. What could have become of the brute?
I fingered my pistol, ready for a scrimmage at close quarters. It
seemed inevitable.
CHAPTER XXIV.
DEATH OF MIGUEL.

N ED turned to us suddenly, and I thought there was a wild look in


his eyes. The beads of perspiration clustered thick on his
forehead, and his cheeks were burning.
“We’ll escape ’em yet!” he cried in excited tones, which
nevertheless had a ring of triumph in them. “Let’s swim out to the
boat, scramble on board, and take possession of her!”
Here was an audacious idea with a vengeance!
“It’s all very fine to say ‘scramble on board,’” exclaimed Mr. Triggs;
“but do you suppose the negroes will allow us calmly to do such a
thing? Why, they’ll knock us on the head the instant we get
alongside.”
“There’s no time to argify!” cried Ned in loud emphatic tones. “If we
stay here to fight it out with those swabs in our rear, we’ll all be killed
to a dead sartinly or taken prisoners. There are eight of ’em at least,
and all armed to the teeth.”
“Right you are then,” answered the gunner; “let’s take to the water.
’Tis a desperate venture, but you may depend upon me to back you
up through thick and thin.”
“Can you swim?” asked Ned, turning hurriedly to me.
“Yes, very well,” I answered.
The boat was slowly approaching the shore, being now distant
about fifty yards or so. It would have been easy for her to land, for
there was not much surf.
The pirates were redoubling their efforts to catch us up; though I
do not suppose that it entered their heads for a moment that we
were about to put into execution any such desperate plan as that
proposed by Ned Burton.
We had halted for a brief moment on the margin of the waves. The
pirates were now of course bearing swiftly down on us. There were
eight or ten of them altogether, and they were near enough for me to
see the expression of gratified revenge which was overspreading
their countenances as they felt the conviction that their prey was at
length within their grasp.
But there is many a slip between the cup and the lip.
“We must chuck away our weapons!” shouted Ned; “but I’m blest if
I don’t empty my barrel fust.” And so saying he hurriedly dropped on
one knee, and levelling his piece with the utmost coolness and
precision fired.
Truly sped the bullet. Miguel gave one spasmodic leap into the air,
and then fell with a thud on the sands—a lifeless corpse.
I had already thrown my pistol into the sea, stripped off my jacket,
and got rid of my shoes. The gunner had done the same.
Ned rose swiftly to his feet without a word, and we all rushed into
the water with the utmost celerity.
The fiendish yells to which our pursuers gave vent on seeing
Miguel fall beggar description; and they were renewed again and
again as they saw that we were trying to evade them by swimming
out to the boat.
One or two of their number opened fire upon us as soon as they
could collect themselves sufficiently; and the others shouted in a
warning manner to the negroes in the boat, evidently directing their
attention to our ruse, and ordering them to repel any attempt we
might make on their craft.
The bullets, fortunately, did not hit us, for we were already in deep
water, and a very small portion of our persons was visible to the
marksmen.
What we had to dread was a hostile attitude on the part of the
negroes; and already I saw that the latter had ceased rowing, and
were standing up in the boat brandishing their long paddles. In their
belts I fancied I detected knives. As Ned had prophesied, the bulky
form occupying the stern-sheets was that of the negress we had
formerly seen at the shanty, so there was little doubt as to the
identity of the two oarsmen.
As the shore shelved rapidly, we very soon got out of our depth,
and began to swim vigorously in the direction of the boat. The latter
had not yet lost her way, and was gliding slowly toward us. I think,
too, that the tide must have been ebbing, for it appeared to me that
we cleft the waters at a great pace.
The negroes looked very determined as we approached, and I
now saw that one of them had a pistol in one hand and his paddle in
the other.
A volley from the shore was now fired at us by the enemy. Some
bullets whistled over our heads and splashed into the water ahead of
us, one or two of them very nearly striking the boat.
I glanced fearfully over my shoulder in the direction of the shore,
and saw that the pirates were reloading their rifles. None of them
had attempted to follow us into the sea, much to my surprise. Either
they could not swim, or they thought it less trouble to rely on the co-
operation of the negroes, to whom they continued to yell orders in
loud and threatening tones.
When we got within easy speaking distance, Mr. Triggs addressed
the negroes in English.
“If you take us on board, Johnny,” he said, “and convey us safely
away from the island, we’ll give you fifty pounds.”
Ned also jabbered something to them in his smattering of Spanish,
as he thought they might be ignorant of English.
Meanwhile we did not relax our efforts to gain the boat’s side.
I saw the negro who was grasping the pistol begin to slowly raise
his arm. Both men looked savage and determined. The fat negress
still sat in the stern-sheets with a bewildered expression on her
bloated face and her blubber lips widely parted.
My heart sank within me, and I was beginning to feel terribly
fatigued. A scrimmage on board the boat would be, I felt, quite
beyond my powers. It was a question whether I should even have
sufficient strength left to clamber on board. Even the negress could
easily keep me at bay if she chose. I knew that. But as yet she
showed no disposition to join in the impending fray.
“Look out! the swab’s going to shoot,” came from Ned in warning
tones.
The next moment a dart of flame issued from the boat, and a bullet
whizzed away harmlessly somewhere.
In spite of my rapidly failing powers, I could not help giving a shout
of astonishment, for I had particularly noticed that the negro had
deliberately aimed a long way above our heads.
The mystery was quickly solved. The negro leaned forward, and in
a vile lingo of broken English told us that he and his mate were
willing to save us, but that they must pretend to defend their boat
from our attack, and that we must go through the pantomime of
capturing it and utterly defeating them.
At first we were all suspicious that this was a trap, but the negroes
assured us that they would not hurt a hair of our heads, and implored
us to scramble on board as quickly as possible, as they were just as
eager to leave the island as we were.
What a blessed relief it was to hear this, and moreover to find that
it was a bonâ fide and genuine ruse on the negroes’ part! Never in
our wildest dreams had we expected such good-fortune as this.
The sham fight was really carried out admirably. The negroes and
the negress kept up a really awful succession of war-cries as they
rushed from one side to the other—at the imminent risk of capsizing
the boat—brandishing their paddles, and bringing them down with
resounding blows upon the gunwale, varying this procedure with
firing an occasional pistol, and making imaginary stabs with knives.
If I had not felt so done up, I should have enjoyed the fun.
At length we had scrambled in over the gunwale, and after a short
and apparently desperate encounter, had worsted the negroes, who
lay shamming death in the bottom of the boat; whilst old “Mother
Bunch,” clasping her pickaninny to her breast, had fallen back in the
stern-sheets in an apparently fainting condition.
The pirates seemed crazy at the turn affairs had taken. Some of
them rushed into the sea and began swimming out in our direction,
whilst others opened a withering fire upon us.
Mr. Triggs and Ned, chuckling to themselves, seized the oars, and
commenced pulling the boat out to sea. It was out of my power to
assist them.
CHAPTER XXV.
WE ESCAPE TO SEA.

O NE or two bullets struck the boat, but most fortunately none of


us got hit. A brisk fire, however, was kept up for some minutes,
and many of the deadly little missiles flew about us with their
ominous pings, and then buried themselves harmlessly in the sea.
The pirates must have been thunderstruck at our apparently
successful attack upon the armed negroes, and the game way in
which we walked off with the boat under their very noses. It was of
course extremely tantalizing for them, especially as they had felt so
sure of capturing us.
However, we were not out of the wood yet, as we were presently
to discover.
For some minutes I lay in the bows of the boat, feeling wretchedly
ill and thoroughly done up. How I wished I could get rid of my
saturated clothes and don dry ones, for I began to feel chilled to the
bone.
The gunner and Ned Burton were well to the fore at this crisis in
our fortunes. Luckily, they both had iron constitutions, with plenty of
stamina and reserve of force; in proof of which they rowed like
madmen, so as to get the boat out of range of the musketry fire
which was being continuously kept up from the shore.
One of the negroes, seeing that I was rather in a collapsed state,
crawled along the bottom of the boat to me, carrying in his hand a
green cocoa-nut, of which there was a supply in the stern-sheets.
With his knife he cut off the top, and handed me the brimming nut.
“Drink him, massa,” he whispered; “plenty mosh good.”
I needed no second invitation, but drank the contents in one long
delicious draught. That dusky negro was like a ministering angel,
and I told him so with as much emphasis as I could muster up.
I now began to feel more myself again, and by great good-fortune
we began to move out of the dense volcanic atmosphere into the
bright sunlight which reigned beyond. I rejoiced greatly at this, for it
meant dry clothes for us all.
A spent bullet or slug struck the boat near the water-line. I raised
myself and glanced over the gunwale.
The pirate chief and his myrmidons were still on the beach, and
occasionally fired a shot at us; but I perceived that we were fast
gliding out of range. Not far from the spot where the desperadoes
stood was a dark object, which I knew must be the corpse of Miguel.
As I gazed at the group, they suddenly ceased firing, and with a
parting volley of angry shouts which came but faintly over the waters,
they turned their backs on us, and started off at a sharp run across
the sandhills in the direction of the interior.
I instantly drew my companions’ attention to this fact.
“We haven’t done with the rascals yet, I’m afraid,” said the gunner,
glancing anxiously at their retiring forms. “They’re making for the
creek on t’other side of the island, and will pursue us in the brig.”
“That will be their little game, no doubt,” observed Ned
thoughtfully, “and we must do our level best to circumvent ’em.
Having had the good-fortune, under Divine providence, to escape
from the island, we may fairly hope that another little spell of good-
fortune is in store for us.”
Ned was always very sanguine, and consequently was often
disappointed; but his courage was indomitable.
I now felt so much better that I seized a spare oar—of which there
were several in the boat—and began to pull, begging the negroes to
give my shipmates each a cocoa-nut, as I felt sure that they must be
suffering intensely from thirst.
“Good idea of yours, Mr. Darcy,” said Ned, who had overheard my
remark. “I just about feel as if I could drink a brewery dry at this
moment. I tell you what, though; I wish that there shegro warn’t in the
starn-sheets. I reckon she’d turn the scale at sixteen stone!”
I glanced at “Mother Bunch.” Now that the pirates had turned tail,
she no longer deemed it necessary to masquerade, and was sitting
bolt upright, with one podgy hand grasping the tiller, and her full
moonlike visage expansive with smiles, her blubber lips being so
widely parted that you could see every tooth in her head. At her feet
the pickaninny lay crowing and kicking, as if it thought there was
something very comical in the whole adventure.
The negroes were now as busy as bees. One of them handed up
cocoa-nuts to Mr. Triggs and Ned, while the other seized an oar and
backed up my efforts to improve the speed of the craft.
We were steering straight out to sea. The surface of the water was
less disturbed than it had been, owing to the cessation of the
earthquakes, and light draughts of air seemed to be working their
way up from the offing. It was probable that a sea-breeze would
soon set in, and this might be of great benefit to us, as there was a
mast and sail in the boat.
“We’re awfully grateful to you Johnnies,” observed the gunner, as
he threw his empty cocoa-nut shell overboard. “If it hadn’t been for
you, we should probably have had our throats cut by those villains
ashore. Now I want to know if this boat belongs to you, and whether
you will stick to us and do your best to land us in the island of Cuba.
The day we get back to our ship the Rattler you shall have your fifty
pounds—that I can promise you on the word of an Englishman.”
The negro who had been handing up the nuts grinned, and
scratched his head. He evidently did not half understand Mr. Triggs’s
long speech. However, after a good deal of trouble and numerous
misunderstandings, we managed to extract the following information
from them. As we had supposed, they were the slaves of the pirates,
and were employed by them to raise garden produce, and to assist
in unloading vessels which had been captured and brought into the
creek. Being skilful fishermen, they were allowed to make use of a
boat; and as finny spoils were to be more plentifully obtained in the
waters on the west side of the island, they usually kept their craft
upon the beach above high-water mark—the creek being on the
eastern seaboard. On this eventful morning, they had started very
early on a fishing excursion, and were actually afloat when the
terrible seismic disturbances commenced. Frightened out of their
wits, and almost swamped by the tidal waves which swept the sea,
they pulled about in various directions, hardly knowing where to go
for safety. At length they determined to land, as they were much
afraid of being upset and drowned. No sooner had they drawn their
boat up on the beach than the volcanic outburst commenced, and
added infinitely to their terror. It was the last straw, and they
determined to quit the island for ever, fully believing that it had been
taken possession of by evil spirits; but it was a long time before they
could muster up enough courage to launch their boat afresh and
start on their perilous journey. It must have been just after they had
done so that we appeared upon the scene. Having in their early days
lived in some of the British West India islands, they felt disposed to
be friendly towards Englishmen in distress; and as they were much
afraid that the pirates would force them to return to the island
whether they liked it or not, it was hurriedly decided to assist us if
possible in our evident determination to escape, and then sail away
to other climes. The reward of fifty pounds they ignored—so we
understood them to say. That is the gist of what the darkies told us.
We now held a brief council of war, as it was necessary to decide
upon some plan of action, and that quickly.
We were unanimously of opinion that we should pull straight out to
sea and trust to meeting a favourable breeze, or, better still, a
friendly vessel.
My shipmates tried to insist on my taking a complete rest, and
allowing them and the negroes to pull; but I could not consent to this
plan, tempting as it was, for I was feeling much stronger, and knew
full well that we should have to strain every nerve to escape, as the
pirates were hardly likely to sit down quietly and twirl their thumbs
while they had one or perhaps two vessels in the roadstead on the
other side of the island.
That we should be chased was a dead certainty, especially as it
was evident that the volcanic outbursts were now diminishing in
violence. The pirates would naturally be anxious for the safety of any
property they might have upon the island; but still our escape was of
much more serious import to them, for, of course, they knew only too
well that we should denounce them to the authorities and betray the
whereabouts of their island.
We pulled vigorously, therefore, often casting anxious glances
towards the jutting capes which marked the extremities of the
pirates’ lair. A thick curtain of smoke hung over the centre of the
island and obscured the view.
“Ha!” cried Ned, “yonder comes the brig, or one of their blooming
craft.”
CHAPTER XXVI.
CONCLUSION.

R OUND the southernmost point of the island a small vessel was


creeping stealthily. Owing to the lack of wind she could set no
canvas, but was evidently being propelled by a number of sweeps.
Undoubtedly it was the brig. I recognized her at once.
Naturally her progress was slow, but our boat was unwieldy and
had no great turn of speed. The draughts of air were the merest
catspaws, and scarcely ruffled the surface of the water. Flying-fish
sprang about us, and occasionally a bonito. The sun was mounting
high in the heavens and casting down rays of burning heat. A track
of molten gold stretched over the deep, the glare from which was
almost intolerable.
“Mother Bunch” shut her jaws with a snap when her dark, round
eyes fell on the shadowy vessel. It was as if a crocodile had closed
with some succulent morsel. The pickaninny began to roar lustily as
if it had a dim presentiment of coming evil. The two negroes
jabbered excitedly in some strange and guttural dialect.
“The brig can’t make much way,” said Ned, fixing his eyes intently
upon her. “I reckon we can outstrip her as things go at present. If a
favourable breeze springs up, however, she’ll overhaul us hand-
over-fist, and then we may look out for squalls.”
“The worst of it is, she’s got guns aboard,” observed Mr. Triggs
anxiously. “Now, if she could creep up within range, she might
pepper us in a mighty unpleasant manner—there’s no question
about that.”
“I wonder if she has any boats with her,” exclaimed I. “It might be
equally unpleasant if she sent some of them in chase of us.”
Ned looked intently across the sea, shading his eyes with his
hand.
“Boats they have, sure enough,” he said after a long survey. “Why,
two of ’em is atowin’ of her!”
“That’s what the sharks are up to, is it?” observed the gunner. “I
tell you what, that’ll make ’em slip along a bit faster than we
expected.”
“What arms are there in the boat?” asked Ned, lying on his oar for
a moment.
The negroes produced their store of weapons, and laid them down
for our inspection. It was a sorry enough lot.
Two extremely old-fashioned pistols, one fairly effective cutlass
(used by the negroes for cutting their way through the dense
jungles), and two rusty and jagged daggers. These constituted our
armoury.
As we were gazing at them rather hopelessly, and demanding
ammunition for the pistols, “Mother Bunch” produced a weighty-
looking club, armed with metal spikes, from some corner of the
stern-sheets, and with many grins and exclamations of satisfaction,
whirled it around her head in a bellicose fashion.
“Bravo, my shegro brave and true!” shouted Ned in great delight.
“We’ll let you go for some of them swabs and brain ’em by-and-by,
jiggered if we don’t. Amazons aren’t in the running when you’re out
on the war-path, I reckon!”
“She is more likely to capsize the boat than anything else if it
comes to a scrimmage,” said the gunner grimly.
It was fortunate that “Mother Bunch” did not understand this
ungallant remark, or Mr. Triggs’s head might have made
acquaintance with the Amazonian club!
How we longed for a little breeze to help us on our way and cool
the air! Our saturated clothes had dried in the hot sun; but our
exertions made us perspire so freely that it seemed probable that
before long they would be in much the same state again.
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!

ebookfinal.com

You might also like