1. iOS 7 Programming Cookbook 2nd Edition Vandad
Nahavandipoor download
https://ebookname.com/product/ios-7-programming-cookbook-2nd-
edition-vandad-nahavandipoor/
Get Instant Ebook Downloads – Browse at https://ebookname.com
2. Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...
iOS 4 Programming Cookbook Solutions Examples for
iPhone iPad and iPod touch Apps 1st Edition Vandad
Nahavandipoor
https://ebookname.com/product/ios-4-programming-cookbook-
solutions-examples-for-iphone-ipad-and-ipod-touch-apps-1st-
edition-vandad-nahavandipoor/
Writing Game Center Apps in iOS Bringing Your Players
Into the Game 1st Edition Vandad Nahavandipoor
https://ebookname.com/product/writing-game-center-apps-in-ios-
bringing-your-players-into-the-game-1st-edition-vandad-
nahavandipoor/
iOS and OS X Network Programming Cookbook 1st Edition
Jon Hoffman
https://ebookname.com/product/ios-and-os-x-network-programming-
cookbook-1st-edition-jon-hoffman/
Handbook of Ecological and Ecosystem Engineering 1st
Edition Majeti Narasimha Vara Prasad
https://ebookname.com/product/handbook-of-ecological-and-
ecosystem-engineering-1st-edition-majeti-narasimha-vara-prasad/
3. Case Files Pediatrics Sixth Edition Eugene C. Toy
https://ebookname.com/product/case-files-pediatrics-sixth-
edition-eugene-c-toy/
Water Infrastructure Issues 1st Edition James D.
Haffner
https://ebookname.com/product/water-infrastructure-issues-1st-
edition-james-d-haffner/
American Sign Language the Easy Way 2nd Edition David
A. Stewart
https://ebookname.com/product/american-sign-language-the-easy-
way-2nd-edition-david-a-stewart/
The Farther Adventures of Robinson Crusoe The Stoke
Newington Edition Daniel Defoe (Editor)
https://ebookname.com/product/the-farther-adventures-of-robinson-
crusoe-the-stoke-newington-edition-daniel-defoe-editor/
Problem Solved A Primer for Design and Communication
First Edition Michael Johnson
https://ebookname.com/product/problem-solved-a-primer-for-design-
and-communication-first-edition-michael-johnson/
4. The hydrogen economy Opportunities and challenges
Michael Ball
https://ebookname.com/product/the-hydrogen-economy-opportunities-
and-challenges-michael-ball/
9. Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1. Implementing Controllers and Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1. Displaying Alerts with UIAlertView 23
1.2. Creating and Using Switches with UISwitch 32
1.3. Customizing the UISwitch 36
1.4. Picking Values with the UIPickerView 39
1.5. Picking the Date and Time with UIDatePicker 45
1.6. Implementing Range Pickers with UISlider 50
1.7. Customizing the UISlider 54
1.8. Grouping Compact Options with UISegmentedControl 59
1.9. Presenting and Managing Views with UIViewController 63
1.10. Presenting Sharing Options with UIActivityViewController 67
1.11. Presenting Custom Sharing Options with UIActivityViewController 73
1.12. Implementing Navigation with UINavigationController 79
1.13. Manipulating a Navigation Controller’s Array of View Controllers 85
1.14. Displaying an Image on a Navigation Bar 86
1.15. Adding Buttons to Navigation Bars Using UIBarButtonItem 88
1.16. Presenting Multiple View Controllers with UITabBarController 94
1.17. Displaying Static Text with UILabel 101
1.18. Customizing the UILabel 105
1.19. Accepting User Text Input with UITextField 108
1.20. Displaying Long Lines of Text with UITextView 118
1.21. Adding Buttons to the User Interface with UIButton 123
1.22. Displaying Images with UIImageView 127
1.23. Creating Scrollable Content with UIScrollView 132
1.24. Loading Web Pages with UIWebView 137
1.25. Displaying Progress with UIProgressView 141
1.26. Constructing and Displaying Styled Texts 143
iii
10. 1.27. Presenting Master-Detail Views with UISplitViewController 148
1.28. Enabling Paging with UIPageViewController 153
1.29. Displaying Popovers with UIPopoverController 158
2. Creating Dynamic and Interactive User Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
2.1. Adding Gravity to Your UI Components 171
2.2. Detecting and Reacting to Collisions Between UI Components 172
2.3. Animating Your UI Components with a Push 180
2.4. Attaching Multiple Dynamic Items to Each Other 184
2.5. Adding a Dynamic Snap Effect to Your UI Components 189
2.6. Assigning Characteristics to Your Dynamic Effects 192
3. Auto Layout and the Visual Format Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
3.1. Placing UI Components in the Center of the Screen 201
3.2. Defining Horizontal and Vertical Constraints with the Visual Format
Language 203
3.3. Utilizing Cross View Constraints 210
3.4. Configuring Auto Layout Constraints in Interface Builder 217
4. Constructing and Using Table Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
4.1. Populating a Table View with Data 225
4.2. Using Different Types of Accessories in a Table View Cell 229
4.3. Creating Custom Table View Cell Accessories 232
4.4. Enabling Swipe Deletion of Table View Cells 235
4.5. Constructing Headers and Footers in Table Views 237
4.6. Displaying Context Menus on Table View Cells 246
4.7. Moving Cells and Sections in Table Views 251
4.8. Deleting Cells and Sections from Table Views 257
4.9. Utilizing the UITableViewController for Easy Creation of Table Views 268
4.10. Displaying a Refresh Control for Table Views 274
5. Building Complex Layouts with Collection Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
5.1. Constructing Collection Views 281
5.2. Assigning a Data Source to a Collection View 284
5.3. Providing a Flow Layout to a Collection View 285
5.4. Providing Basic Content to a Collection View 288
5.5. Feeding Custom Cells to Collection Views Using .xib Files 294
5.6. Handling Events in Collection Views 299
5.7. Providing a Header and a Footer in a Flow Layout 303
5.8. Adding Custom Interactions to Collection Views 308
iv | Table of Contents
11. 5.9. Providing Contextual Menus on Collection View Cells 311
6. Storyboards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
6.1. Adding a Navigation Controller to a Storyboard 316
6.2. Passing Data from One Screen to Another 318
6.3. Adding a Tab Bar Controller to a Storyboard 325
6.4. Introducing Custom Segue Transitions to Your Storyboard 328
6.5. Placing Images and Other UI Components on Storyboards 332
7. Concurrency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
7.1. Constructing Block Objects 342
7.2. Accessing Variables in Block Objects 346
7.3. Invoking Block Objects 352
7.4. Performing UI-Related Tasks with GCD 354
7.5. Executing Non-UI Related Tasks Synchronously with GCD 358
7.6. Executing Non-UI Related Tasks Asynchronously with GCD 361
7.7. Performing Tasks after a Delay with GCD 368
7.8. Performing a Task Only Once with GCD 371
7.9. Grouping Tasks Together with GCD 373
7.10. Constructing Your Own Dispatch Queues with GCD 377
7.11. Running Tasks Synchronously with Operations 380
7.12. Running Tasks Asynchronously with Operations 387
7.13. Creating Dependency Between Operations 393
7.14. Creating Timers 395
7.15. Creating Concurrency with Threads 400
7.16. Invoking Background Methods 406
7.17. Exiting Threads and Timers 407
8. Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
8.1. Enabling Security and Protection for Your Apps 418
8.2. Storing Values in the Keychain 422
8.3. Finding Values in the Keychain 424
8.4. Updating Existing Values in the Keychain 429
8.5. Deleting Exiting Values in the Keychain 432
8.6. Sharing Keychain Data Between Multiple Apps 434
8.7. Writing to and Reading Keychain Data from iCloud 440
8.8. Storing Files Securely in the App Sandbox 443
8.9. Securing Your User Interface 446
9. Core Location and Maps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
9.1. Creating a Map View 450
9.2. Handling the Events of a Map View 452
Table of Contents | v
12. 9.3. Pinpointing the Location of a Device 453
9.4. Displaying Pins on a Map View 455
9.5. Displaying Pins with Different Colors on a Map View 459
9.6. Displaying Custom Pins on a Map View 465
9.7. Converting Meaningful Addresses to Longitude and Latitude 468
9.8. Converting Longitude and Latitude to a Meaningful Address 470
9.9. Searching on a Map View 472
9.10. Displaying Directions on the Map 475
10. Implementing Gesture Recognizers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
10.1. Detecting Swipe Gestures 483
10.2. Detecting Rotation Gestures 485
10.3. Detecting Panning and Dragging Gestures 489
10.4. Detecting Long-Press Gestures 491
10.5. Detecting Tap Gestures 495
10.6. Detecting Pinch Gestures 497
11. Networking, JSON, XML, and Sharing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
11.1. Downloading Asynchronously with NSURLConnection 501
11.2. Handling Timeouts in Asynchronous Connections 504
11.3. Downloading Synchronously with NSURLConnection 506
11.4. Modifying a URL Request with NSMutableURLRequest 508
11.5. Sending HTTP GET Requests with NSURLConnection 509
11.6. Sending HTTP POST Requests with NSURLConnection 511
11.7. Sending HTTP DELETE Requests with NSURLConnection 513
11.8. Sending HTTP PUT Requests with NSURLConnection 514
11.9. Serializing Arrays and Dictionaries into JSON 516
11.10. Deserializing JSON into Arrays and Dictionaries 518
11.11. Integrating Social Sharing into Your Apps 521
11.12. Parsing XML with NSXMLParser 525
12. Audio and Video. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
12.1. Playing Audio Files 531
12.2. Handling Interruptions While Playing Audio 534
12.3. Recording Audio 535
12.4. Handling Interruptions While Recording Audio 542
12.5. Playing Audio over Other Active Sounds 543
12.6. Playing Video Files 547
12.7. Capturing Thumbnails from Video Files 551
12.8. Accessing the Music Library 554
13. Address Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
vi | Table of Contents
13. 13.1. Requesting Access to the Address Book 564
13.2. Retrieving a Reference to an Address Book 568
13.3. Retrieving All the People in the Address Book 571
13.4. Retrieving Properties of Address Book Entries 573
13.5. Inserting a Person Entry into the Address Book 577
13.6. Inserting a Group Entry into the Address Book 581
13.7. Adding Persons to Groups 584
13.8. Searching the Address Book 587
13.9. Retrieving and Setting a Person’s Address Book Image 592
14. Files and Folder Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
14.1. Finding the Paths of the Most Useful Folders on Disk 603
14.2. Writing to and Reading from Files 605
14.3. Creating Folders on Disk 610
14.4. Enumerating Files and Folders 612
14.5. Deleting Files and Folders 618
14.6. Saving Objects to Files 621
15. Camera and the Photo Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
15.1. Detecting and Probing the Camera 627
15.2. Taking Photos with the Camera 632
15.3. Taking Videos with the Camera 636
15.4. Storing Photos in the Photo Library 639
15.5. Storing Videos in the Photo Library 644
15.6. Retrieving Photos and Videos from the Photo Library 646
15.7. Retrieving Assets from the Assets Library 649
15.8. Editing Videos on an iOS Device 656
16. Multitasking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
16.1. Detecting the Availability of Multitasking 664
16.2. Completing a Long-Running Task in the Background 665
16.3. Adding Background Fetch Capabilities to Your Apps 669
16.4. Playing Audio in the Background 678
16.5. Handling Location Changes in the Background 682
16.6. Saving and Loading the State of Multitasking Apps 684
16.7. Handling Network Connections in the Background 688
16.8. Opting Out of Multitasking 691
17. Notifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
17.1. Sending Notifications 694
17.2. Listening for and Reacting to Notifications 696
17.3. Listening and Reacting to Keyboard Notifications 700
Table of Contents | vii
14. 17.4. Scheduling Local Notifications 707
17.5. Listening for and Reacting to Local Notifications 711
17.6. Handling Local System Notifications 714
17.7. Setting Up Your App for Push Notifications 718
17.8. Delivering Push Notifications to Your App 724
17.9. Reacting to Push Notifications 732
18. Core Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
18.1. Creating a Core Data Model with Xcode 737
18.2. Generating Class Files for Core Data Entities 741
18.3. Creating and Saving Data Using Core Data 745
18.4. Reading Data from Core Data 747
18.5. Deleting Data from Core Data 750
18.6. Sorting Data in Core Data 752
18.7. Boosting Data Access in Table Views 754
18.8. Implementing Relationships in Core Data 761
18.9. Fetching Data in the Background 768
18.10. Using Custom Data Types in Your Core Data Model 772
19. Dates, Calendars, and Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779
19.1. Requesting Permission to Access Calendars 784
19.2. Retrieving Calendar Groups on an iOS Device 790
19.3. Adding Events to Calendars 792
19.4. Accessing the Contents of Calendars 796
19.5. Removing Events from Calendars 799
19.6. Adding Recurring Events to Calendars 803
19.7. Retrieving the Attendees of an Event 808
19.8. Adding Alarms to Calendars 811
19.9. Handling Event Changed Notifications 814
19.10. Presenting Event View Controllers 816
19.11. Presenting Event Edit View Controllers 822
20. Graphics and Animations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
20.1. Enumerating and Loading Fonts 833
20.2. Drawing Text 835
20.3. Constructing, Setting, and Using Colors 836
20.4. Drawing Images 841
20.5. Constructing Resizable Images 845
20.6. Drawing Lines 850
20.7. Constructing Paths 858
20.8. Drawing Rectangles 862
20.9. Adding Shadows to Shapes 866
viii | Table of Contents
15. 20.10. Drawing Gradients 873
20.11. Moving Shapes Drawn on Graphic Contexts 882
20.12. Scaling Shapes Drawn on Graphic Contexts 886
20.13. Rotating Shapes Drawn on Graphic Contexts 889
20.14. Animating and Moving Views 890
20.15. Animating and Scaling Views 900
20.16. Animating and Rotating Views 901
20.17. Capturing a Screenshot of Your View into an Image 903
21. Core Motion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
21.1. Detecting the Availability of an Accelerometer 908
21.2. Detecting the Availability of a Gyroscope 910
21.3. Retrieving Accelerometer Data 911
21.4. Detecting Shakes on an iOS Device 915
21.5. Retrieving Gyroscope Data 916
22. iCloud. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 919
22.1. Setting Up Your App for iCloud 920
22.2. Storing and Synchronizing Dictionaries in iCloud 924
22.3. Creating and Managing Folders for Apps in iCloud 929
22.4. Searching for Files and Folders in iCloud 936
22.5. Storing User Documents in iCloud 946
22.6. Managing the State of Documents in iCloud 961
23. Pass Kit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 965
23.1. Creating Pass Kit Certificates 968
23.2. Creating Pass Files 975
23.3. Providing Icons and Images for Passes 984
23.4. Preparing Your Passes for Digital Signature 987
23.5. Signing Passes Digitally 989
23.6. Distributing Passes Using Email 993
23.7. Distributing Passes Using Web Services 995
23.8. Enabling Your iOS Apps to Access Passes on iOS Devices 997
23.9. Interacting with Passbook Programmatically 1003
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1007
Table of Contents | ix
17. Preface
This edition of the book is not just an update, but a total remake of the previous edition.
iOS 7 changed everything: the look and feel, the way we use our iOS devices, and most
importantly, the way we program for iOS devices. This called for a substantial rewrite
indeed. I have added roughly 50 new recipes to this book, talking about things such as
UIKit dynamics, collection views, the keychain, push notifications, and whatnot. I have
also gone through all the example codes and figures and updated them for iOS 7.
iOS 7 is a huge step forward for this amazing operating system that we all, as program‐
mers and users, have grown to love and enjoy programming for. You must have noticed
how the focus of iOS 7 is on being dynamic: how your UI should adapt to various
movements and motions that can be applied to the device. What I mean by that is Apple
wants developers to really look at the details of their apps and bring real-world physics
and dynamics into them. That’s why Apple introduced UIKit Dynamics to the SDK, and
that is why this book has a whole chapter dedicated to this concept. The more expensive
a high-end device such as the new iPhone becomes, the more demanding the users will
get as well. Nobody blames them, though! They have just bought a fantastic and top-
of-the-line new iPhone or iPad and they want to see amazing apps running on them,
leveraging all the capabilities that those devices have to offer.
That is why now more than ever developers have to get an in-depth knowledge of the
SDK and what the SDK has to offer to the developers so that we can create better and
faster apps for iOS users. Apple introduced a lot of cool new APIs to the iOS 7 SDK, and
we are going to explore them in this book.
The focus of iOS 7 is dynamics!
Before you read about this book, maybe you’d like to know about my background a bit
and how I can help you through this journey. I will just briefly let you know who I am
and how I got to love iOS. I started out writing Basic code for my Commodore 64 when
Iwasakid.IthenmovedontobuymyownPCandstartedexperimentingwithAssembly
code. At first, it was 8-bit Assembly for DOS. I then moved onto writing my own hobby
xi
18. operating system, which was never really released as a commercial product, for 32-bit
Intel x86 CPU architectures.
Among all the programming languages that I have programmed in, Assembly and
Objective-C are the two that have really been different from the others, and I’ve really
liked them. Assembly because of the purity of the language: a command does only one
thing and does that one thing well. I believe that I like Objective-C for the same reason,
and in fact iOS shares the same trait with Assembly and Objective-C. Even though iOS
is an operating system and not a programming language, whatever it does, it does it best
and better than its rivals. From its simplicity to the sheer power that you can harvest
from the software and the hardware combined, using technologies such as GCD, the
bar that iOS has set in terms of ease of use and beauty is unprecedented.
This edition of the book has seen all the recipes inside all chapters completely renewed
for iOS 7. All screenshots have been updated, and many more recipes—such as those
related to security and the keychain, UI dynamics, collection views, push and local
notifications, and many more—have exclusively been written for this edition of the
book. I really have had a fun time writing this edition of the book, and packed as it is
with new features, I hope you’ll enjoy reading it. May it be a valuable addition to your
tech-book library.
Audience
I assume you are comfortable with the iOS development environment and know how
to create an app for the iPhone or iPad. This book does not get novice programmers
started but presents useful ways to get things done for iOS programmers ranging from
novices to experts.
Organization of This Book
In this book, we will discuss frameworks and classes that are available in the iOS 7 SDK.
This book does its best to teach you the latest and the greatest APIs. As you know, some
users of your apps may still be on older versions of iOS, so please consider those users
and choose your APIs wisely, depending on the minimum iOS version that you want to
target with your apps.
Apple has recommended that you write your apps so that they support and run on iOS
6 and iOS 7. This means you need to use the latest SDK as your base SDK (the SDK that
youusetocompileyourapp)andchooseiOS6asyourtarget,ifthat’swhatyourbusiness
requirements dictate. If you are required to write your app to support only iOS 7, then
you are in for a lot of fun, as you can use all the cool APIs that have been introduced in
iOS 7 and discussed in this book.
xii | Preface
19. Here is a concise breakdown of the material each chapter covers:
Chapter 1, Implementing Controllers and Views
Explains how Objective-C classes are structured and how objects can be instanti‐
ated. The chapter talks about properties and delegates and subscripting by keys and
indexes. Even if you are competent in Objective-C, I strongly suggest that you read
this chapter, even if you only skim through it, to understand the basic material that
is used in the rest of the book. In this chapter, we will also explore the common
usage of various UI components, such as alert views, segmented controls, switches,
and labels. We will also talk about customizing these components with the latest
APIs provided in the SDK.
Chapter 2, Creating Dynamic and Interactive User Interfaces
Talks about UIKit Dynamics, the newest addition to the UIKit framework. These
dynamics allow you to add real-life physics and dynamics to your UI components.
This will allow you to create even livelier user interfaces with very small effort on
your side.
Chapter 3, Auto Layout and the Visual Format Language
Explains how you can take advantage of Auto Layout in the iOS SDK in order to
construct your UI in such a way that it can be resized and stretched to pretty much
any screen dimension.
Chapter 4, Constructing and Using Table Views
Shows how you can work with table views to create professional-looking iOS ap‐
plications. Table views are very dynamic in nature, and as a result, programmers
sometimes have difficulty understanding how they should work with them. By
reading this chapter and trying out the example code, you will gain the knowledge
that is required to comfortably work with table views.
Chapter 5, Building Complex Layouts with Collection Views
Collection views have been available to OS X programmers for quite some time
now, and Apple decided to provide the same APIs to iOS programmers in the iOS
SDK. Collection views are very much like table views, but they are much more
configurable and dynamic. Where in table views we have the concept of sections
and rows in each section, collection views bring columns to the equation as well,
so that you can display many items in one row if you want to. In this chapter we
will have a look at all the great user interfaces that you can create using collection
views.
Chapter 6, Storyboards
Demonstrates the process of storyboarding, the new way to define the connections
between different screens in your app. The great thing about storyboarding is that
you don’t have to know anything about iOS programming to get a simple app run‐
ning. This helps product analysts, product owners, or designers who work inde‐
pendently of developers to gain knowledge of the UI components iOS offers and to
Preface | xiii
20. buildmorerobustproducts.Programmerscanalsotakeadvantageofstoryboarding
to easily create prototypes. Storyboarding is just fun, whether you do it on paper
or using Xcode.
Chapter 7, Concurrency
As humans, we can do many things simultaneously without thinking much about
it. With advances in computer technology, mobile devices are also able to multitask,
and they provide programmers with tools and mechanisms that can accomplish
more than one task at the same time. This is called concurrency. In this chapter, you
will learn about Grand Central Dispatch, Apple’s preferred way of achieving con‐
currency in iOS. You will also learn about timers, threads, and operations.
Chapter 8, Security
iOS is a very secure operating system, and apps that we write for it also have to
adhere to certain security standards and practices. In this chapter, we will discuss
how you can take advantage of keychain APIs to make your apps more secure. We
will also talk about various steps that you can take to make your user interface more
secure.
Chapter 9, Core Location and Maps
DescribeshowyoushoulduseMapKitandCoreLocationAPIstodeveloplocation-
aware iOS applications. First you will learn about maps, and then you will learn
how to detect a device’s location and tailor your maps with custom annotations.
You will also learn about geocoding and reverse geocoding, as well as some of the
methods of the Core Location framework, which are available only in iOS 7.
Chapter 10, Implementing Gesture Recognizers
Demonstrates how to use gesture recognizers, which enable your users to easily and
intuitively manipulate the graphical interface of your iOS applications. In this
chapter, you will learn how to use all available gesture recognizers in the iOS SDK,
with working examples tested on iOS 7.
Chapter 11, Networking, JSON, XML, and Sharing
Demonstrates the built-in JSON and XML parsers. On top of that, this chapter talks
about various networking APIs and how programmers can build social networking
into our apps to allow our users to share their creations and data to social networks
such as Facebook.
Chapter 12, Audio and Video
Discusses the AV Foundation and Media Player frameworks that are available on
the iOS SDK. You will learn how to play audio and video files and how to handle
interruptions, such as a phone call, while the audio or video is being played. This
chapter also explains how to record audio using an iOS device’s built-in micro‐
phone(s). At the end of the chapter, you will learn how to access the Music Library
and play its media content, all from inside your application.
xiv | Preface
21. Chapter 13, Address Book
Explains the Address Book framework and how to retrieve contacts, groups, and
their information from the Address Book database on an iOS device. The Address
Book framework is composed entirely of C APIs. Because of this, many Objective-
C developers find it difficult to use this framework, as compared with frameworks
that provide an Objective-C interface. After reading this chapter and trying the
examples for yourself, you will feel much more confident using the Address Book
framework.
Chapter 14, Files and Folder Management
One of the most important tasks that, as developers, we want to perform in our iOS
apps is manipulating files and folders. Whether this means creating, reading from,
writing to, or deleting them, this chapter contains enough material to get you up
and running with file and folder management in the iOS SDK.
Chapter 15, Camera and the Photo Library
Demonstrates how you can determine the availability of front- and back-facing
cameras on an iOS device. You will also learn how to access the photo library using
the Assets Library framework. At the end of the chapter, you will learn about editing
videos right on an iOS device using a built-in view controller.
Chapter 16, Multitasking
Showsmultitasking-awareapplicationsthatrunbeautifullyoniOSdevices.Youwill
learn about background processing, including how to play audio and retrieve users’
locations in the background, as well as how to download content from a URL while
your application is running in the background. On top of that, we will explore some
of the new APIs that iOS 7 provides to us, in order to enable our apps to download
content periodically while in the background or even while our app is not even
running.
Chapter 17, Notifications
Notificationsareobjectsthatcanbecomposedbyasourceanddeliveredtomultiple
recipients.Inthischapter,wewilldiscussnotifications,includinglocalnotifications
and push notifications, along with how you can use the latest capabilities built into
Xcode to easily enable these features in your own apps.
Chapter 18, Core Data
Describes the details of Core Data stacks and what they are made out of. You will
thenbeabletodesignyourownobject-orienteddatamodelsrightintoXcode,using
the Core Data model editor, and also create and retrieve your objects in Core Data.
On top of that, you will learn how to add your own custom data to Core Data and
how to search for data in the background thread, leaving your UI thread ready to
process user events.
Preface | xv
22. Chapter 19, Dates, Calendars, and Events
Demonstrates the use of the Event Kit and Event Kit UI frameworks in order to
manage calendars and events on an iOS device. You will see how to create, modify,
save, and delete events. You will also learn, through examples, how to add alarms
to calendar events and how to set up CalDAV calendars so that you can share a
single calendar among multiple devices.
Chapter 20, Graphics and Animations
Introduces the Core Graphics framework. You will learn how to draw images and
text on a graphics context; draw lines, rectangles, and paths; and much more. You
will also learn to use the new iOS SDK APIs to capture your views’ contents as
screenshots.
Chapter 21, Core Motion
Explains the Core Motion framework. Using Core Motion, you will access the ac‐
celerometer and the gyroscope on an iOS device. You will also learn how to detect
shakes on a device. Of course, not all iOS devices are equipped with an accelerom‐
eter and a gyroscope, so you will also learn how to detect the availability of the
required hardware.
Chapter 22, iCloud
Shows how to use the iCloud service, which ties devices together and allows them
to share data to provide a seamless user experience as the user moves from one
device to another.
Chapter 23, Pass Kit
Describes Passbook: a virtual wallet, if you will, capable of managing your coupons,
boarding passes, rail and bus tickets, and much more. In this chapter, you will learn
all there is to know in order to be able to create your own digitally signed passes
and distribute them to your users easily.
Additional Resources
From time to time, I refer to official Apple documentation. Some of Apple’s descriptions
are right on the mark, and there is no point in trying to restate them. Throughout this
book, I have listed the most important documents and guides in the official Apple doc‐
umentation that every professional iOS developer should read.
For starters, I suggest that you have a look at the iOS Human Interface Guidelines for
all iOS devices. This document will tell you everything you need to know about devel‐
oping engaging and intuitive user interfaces for all iOS devices. Every iOS programmer
should read this document. In fact, I believe this should be required reading for the
product design and development teams of any company that develops iOS applications.
xvi | Preface
23. I also suggest that you skim through the “iOS App Programming Guide” in the iOS
Developer Library for some tips and advice on how to make great iOS applications.
iOS 7 brings with itself quite a lot of changes to how UI components appear on the
screen.Wewilltalkatgreatlengthaboutthesechangesandhowyou,astheprogrammer,
can use the latest APIs to create great-looking apps for iOS 7. However, I would like to
suggest that you have a look at the iOS 7 UI Transition Guide provided by Apple, which
outlines all the UI changes that have now been made to the latest version of the SDK.
One of the things you will notice when reading Chapter 16 is the use of block objects.
This book concisely explains block objects, but if you require further details on the
subject, I suggest you read “A Short Practical Guide to Blocks”.
Throughout this book, you will see references to “bundles” and loading images and data
from bundles. You will read a concise overview about bundles in this book, but if you
require further information, head over to the “Bundle Programming Guide”.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements
such as variable or function names, databases, data types, environment variables,
statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter‐
mined by context.
This icon signifies a tip, suggestion, or general note.
This icon indicates a warning or caution.
Preface | xvii
24. Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at
https://github.com/oreillymedia/iOS7_programming_cookbook.
This book is here to help you get your job done. In general, if example code is offered
with this book, you may use it in your programs and documentation. You do not need
to contact us for permission unless you’re reproducing a significant portion of the code.
For example, writing a program that uses several chunks of code from this book does
not require permission. Selling or distributing a CD-ROM of examples from O’Reilly
books does require permission. Answering a question by citing this book and quoting
example code does not require permission. Incorporating a significant amount of ex‐
ample code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “iOS 7 Programming Cookbook
by Vandad Nahavandipoor (O’Reilly). Copyright 2014 Vandad Nahavandipoor,
978-1-4493-7242-2.”
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at permissions@oreilly.com.
Safari® Books Online
Safari Books Online (www.safaribooksonline.com) is an on-
demand digital library that delivers expert content in both book and
video form from the world’s leading authors in technology and busi‐
ness.
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research, prob‐
lem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi‐
zations, government agencies, and individuals. Subscribers have access to thousands of
books, training videos, and prepublication manuscripts in one fully searchable database
from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐
fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John
Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT
Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol‐
ogy, and dozens more. For more information about Safari Books Online, please visit us
online.
xviii | Preface
25. How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/iOS7-Programming-Cookbook.
To comment or ask technical questions about this book, send email to bookques
tions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
Andy Oram, my lovely editor, has again done an amazing job going through all the
changes that I made in this edition of the book. In fact, the whole book is updated in
this edition, and all example codes and screenshots have also been updated. I’d like to
alsothankKrzysztofGrobelnyandKrzysztofGutowski,mygreatfriendsandcolleagues,
for tech-reviewing this book. Without their help, this book wouldn’t be in your hands.
I’d like to say thank you to Rachel Roumeliotis, for supporting me and Andy, among all
the other admin work that she did for us behind the scenes. Rachel, you may be quiet,
but we’d have to be blind not to notice your hard work in the background. Also, Meghan
Connolly of O’Reilly has been a fantastic sport, listening to my nagging about paper‐
work, and she has been absolute bliss to work with. A thank-you goes to Jessica Hosman
for helping us a great deal with Git issues. Even though I didn’t believe the simple sol‐
utions that she suggested to me would work, they did, and I looked like a fool.
Last but not least, thank you to Alina Rizzoni, Bruno Packham, and Thomas Packham
for being real friends. I feel blessed to know them, and I appreciate their help and
support.
Preface | xix
27. CHAPTER 1
Implementing Controllers and Views
1.0. Introduction
iOS 7 has introduced a lot of new features to users, as well as tons of new APIs for us
programmers to use and play with. You probably already know that the user interface
has drastically changed in iOS 7. This user interface had stayed intact all the way from
the first version of iOS till now, and because of this, many apps were coded on the
assumption that this user interface would not ever change. Graphic designers are now
faced with the challenge of creating the user interface and thinking about the user ex‐
perience in a way that makes it great for both pre- and post-iOS 7 user interfaces (UIs).
In order to write apps for iOS 7, you need to know some of the basics of the Objective-
C programming language that we will use throughout this book. Objective-C, as its
name implies, is based on C with extensions that allow it to make use of objects. Objects
and classes are fundamental in object-oriented programming (OOP) languages such as
Objective-C, Java, C++, and many others. In Objective-C, like any other object-oriented
language(OOL),youhavenotonlyaccesstoobjects,butalsotoprimitives.Forinstance,
the number –20 (minus twenty) can be expressed simply as a primitive in this way:
NSInteger myNumber = -20;
This simple line of code will define a variable named myNumber with the data type of
NSInteger and sets its value to 20. This is how we define variables in Objective-C. A
variable is a simple assignment of a name to a location in memory. In this case, when
we set 20 as the value of the myNumber variable, we are telling the machine that will
eventually run this piece of code to put the aforementioned value in a memory location
that belongs to the variable myNumber.
All iOS applications essentially use the model-view-controller (MVC) architecture.
Model, view, and controller are the three main components of an iOS application from
an architectural perspective.
1
28. The model is the brain of the application. It does the calculations and creates a virtual
world for itself that can live without the views and controllers. In other words, think of
a model as a virtual copy of your application, without a face!
Aviewisthewindowthroughwhichyourusersinteractwithyourapplication.Itdisplays
what’s inside the model most of the time, but in addition to that, it accepts users’ inter‐
actions. Any interaction between the user and your application is sent to a view, which
then can be captured by a view controller and sent to the model.
The controller in iOS programming usually refers to the view controllers I just men‐
tioned. Think of a view controller as a bridge between the model and your views. This
controller interprets what is happening on one side and uses that information to alter
the other side as needed. For instance, if the user changes some field in a view, the
controller makes sure the model changes in response. And if the model gets new data,
the controller tells the view to reflect it.
In this chapter, you will learn how to create the structure of an iOS application and how
to use views and view controllers to create intuitive applications.
In this chapter, for most of the user interface (UI) components that we
create, we are using a Single View Application template in Xcode. To
reproduce the examples, follow the instructions in “Creating and Run‐
ning Our First iOS App” on page 2. Make sure that your app is uni‐
versal, as opposed to an iPhone or iPad app. A universal app can run
on both iPhone and iPad.
Creating and Running Our First iOS App
Before we dive any deeper into the features of Objective-C, we should have a brief look
at how to create a simple iOS app in Xcode. Xcode is Apple’s IDE (integrated develop‐
ment environment) that allows you to create, build, and run your apps on iOS Simulator
and even on real iOS devices. We will talk more about Xcode and its features as we go
along, but for now let’s focus on creating and running a simple iOS app. I assume that
you’ve already downloaded Xcode into your computer from the Mac App Store. Once
that step is taken care of, please follow these steps to create and run a simple iOS app:
1. Open Xcode if it’s not already open.
2. From the File menu, choose New Project...
3. In the New Project window that appears, on the lefthand side under the iOS cate‐
gory, choose Application and then on the righthand side choose Single View Ap‐
plication. Then press the Next button.
4. On the next screen, for the Product Name, enter a name that makes sense for you.
For instance, you can set the name of your product as My First iOS App. In the
2 | Chapter 1: Implementing Controllers and Views
29. Organization Name section, enter your company’s name, or if you don’t have a
company, enter anything else that makes sense to you. The organization name is
quite an important piece of information that you can enter here, but for now, you
don’t have to worry about it too much. For the Company Identifier field, enter
com.mycompany. If you really do own a company or you are creating this app for a
company that you work with, replace mycompany with the actual name of the com‐
pany in question. If you are just experimenting with development on your own,
invent a name. For the Devices section, choose Universal.
5. Onceyouaredonesettingtheaforementionedvalues,simplypresstheNextbutton.
6. You are now being asked by Xcode to save your project to a suitable place. Choose
a suitable folder for your project and press the Create button.
7. Assoonasyourprojectiscreated,youarereadytobuildandrunit.However,before
you begin, make sure that you’ve unplugged all your iOS devices from your com‐
puter. The reason behind this is that once an iOS device is plugged in, by default,
Xcode will attempt to build and run your project on the device, causing some issues
with provisioning profiles (which we haven’t talked about yet). So unplug your iOS
devices and then press the big Run button on the top-lefthand corner of Xcode. If
you cannot find the Run button, go to the Product menu and select the Run menu
item.
Voilà! Your first iOS app is running in iOS Simulator now. Even though the app is not
exactly impressive, simply displaying a white screen in the simulator, this is just the first
step toward our bigger goal of mastering the iOS SDK, so hold on tight as we embark
on this journey together.
Defining and Understanding Variables
All modern programming languages, including Objective-C, have the concept of vari‐
ables. Variables are simple aliases to locations in the memory. Every variable can have
the following properties:
1. A data type, which is either a primitive, such as an integer, or an object
2. A name
3. A value
You don’t always have to set a value for a variable, but you need to specify its type and
its name. Here are a few data types that you will need to know about when writing any
typical iOS app:
1.0. Introduction | 3
31. “Oh!” cried Florence, precipitating herself towards him, “I’ve
got your letter—but—but, if you’re my brother Harry that’s
come home—the keepers are going to seize you for a
poacher!”
32. Chapter Fifteen.
Father and Son.
Edgar Cunningham got somewhat the better of his
headache as the day went on, and late in the afternoon
insisted on getting out into the fresh air on the terrace, in
the hope that Wyn might make some excuse for coming up
to speak to him. He was hardly fit even for this exertion;
but the open air was always the one thing he cared for, and
the suspense was more endurable so than when he was
shut up in the house.
When his cushions were raised he could see across the
flower garden, over the low wall that bounded it, to the
road that led from the wood and the village, up to the
stables, and to the back of the house; and as his bright
eyes were keen and long-sighted, he often amused himself
with watching the comers and goers, noticing all that went
on, as only those people do who are confined to one place.
To-day, however, as he lay almost flat on his back, he could
not see the road, and it was with a start of surprise that he
looked up and saw his father standing by him.
“I hope, as you are out of doors, that you are better,
Edgar?” he said.
“Oh yes, thanks, almost well,” said Edgar.
“Your boy, little Warren, has been getting into trouble. He
has let down the young bay horse and broken his knees.”
“Wyn! Has he? What had he to do with the horse?” said
Edgar, very much startled as he thought of what Wyn
33. should have been doing.
“He had been driving his mother and her niece to
Ravenshurst as I understand, and went to fetch his sister
from the station. He let down the horse in Coombe Lane.
That is what I am told,” said Mr Cunningham with emphasis,
and using all the advantage his position gave him to look
straight down into Edgar’s face.
“Was he hurt?” said Edgar, looking straight up in return.
Mr Cunningham was very angry with his son, and little
disposed to be merciful to him, though he had not meant to
enter on the subject of the letter if Edgar had been more
manifestly unequal to a discussion.
“He broke his head; I believe nothing serious. He had a
letter for you, which I undertook to deliver myself,” and Mr
Cunningham laid Alwyn’s unopened packet in Edgar’s hand.
Edgar caught his breath, but his face never flinched as his
father went on:
“I was not aware, when you spoke to me the other morning,
that you were already in communication with your brother.”
“I dare say you think it possible that I might have so
deceived you,” said Edgar bitterly. “But my brother made
himself known to me for the first time yesterday. I should
not be waiting here if I had the use of my limbs like other
people. As things are, I’ll beg you to open that letter and
read it at once yourself.”
Edgar’s manner and face were alike defiant, and he was so
indignant at the imputation cast on him that he never saw
that his father’s lips were twitching and that his face was
pale, nor took advantage of the moment of softening.
34. Mr Cunningham took up the packet, and turned round as if
to open and read it, when his attention was caught by three
figures coming up the road towards the house. They
evidently saw him on the terrace, and after a pause and a
word or two came through the gate up the garden.
“What is it? Who is there, father?” cried Edgar, expectant of
any turn of events.
“It is—your brother!” said Mr Cunningham, laying his hand
on the wall, with pale lips, and his eyes fixed on the first
figure approaching him.
Alwyn stood still at the top of the steps and took off his hat.
“I see you know me, sir,” he said; “I did not mean to come
here against your wish. But your keepers have made a
mistake, which perhaps you will explain to them.”
“That will do, blockheads; don’t you know a gentleman
when you see one?” said Mr Cunningham, as the two men,
greatly crestfallen, and muttering a “Beg pardon, I’m sure,
sir,” retreated in haste.
“It is right, sir, that I should explain myself,” said Alwyn,
speaking with evident effort. “I had no intention of forcing
myself on you. If you will have the goodness to read the
letter I gave to my brother, I will go back to London and
wait—”
“No, no, no!” interposed Edgar, struggling up on to his
elbow. “I’d stand by your side if I could stand anywhere. At
least I’ll claim the right to own you.”
Alwyn had not meant to make any advance to Edgar which
might be construed as a defiance, but he now crossed over
35. to the couch and took the offered hand gently in both his
own.
“My father will understand,” he said, “that I should not have
made any approach to you if I had known of the fatal
mischief for which I am responsible. Dear Edgar, lie still; no
one could have done more for me than you have.”
There was a pause. Mr Cunningham moved and sat down in
a chair opposite his sons. Edgar lay back, but with eyes still
fronting his father, while he still held Alwyn’s hand. Alwyn
himself hardly knew what next to do. There was, however,
something about him so unlike the wild youth from whom
the father had parted, so unlike what Mr Cunningham had
imagined as his probable condition, that all previous ideas
were upset.
“Your reappearance,” said Mr Cunningham at length, “is
very sudden after so complete a silence. What is your
reason for coming here?”
Alwyn hesitated, his mouth quivered, and he pointed to the
letter which still lay on Edgar’s knee. Then he dropped his
brother’s hand and made a step or two forward.
“Father,” he said, “I—I beg your pardon. That first, nothing
else. I have made a position for myself, as you will see. I
came partly because I hope to set Whittaker’s character
right with his friends here and to leave no mystery about
my own. But I have nothing to say for myself—as to the
past. I was inexcusable all through.”
“Give me your letter,” said Mr Cunningham. “I will read it; I
make no promises. I—I am glad; it is a satisfaction to me to
hear that you have done well. But personal intercourse is
another question, to which you once attached conditions to
which I am not likely to see my way.”
36. “The conditions, sir,” said Alwyn, “are, I know now, entirely
for you to make. Without your desire I shall not come here
again. Indeed, of course, I cannot.”
“I never felt till now,” burst out Edgar passionately, “what it
is to be helpless. I’ll not ask you to stay without a welcome.
But what my father told me is not with my goodwill. I would
blot out the past I must say—wait—oh! I cannot even speak
for you,” as his breath came in panting gasps and his voice
failed him.
“Hush, hush! I understand,” said Alwyn, much distressed;
“there is no need to tell me. Hush!”
“Don’t linger here for me,” gasped Edgar, resolute still. “It is
—all—nothing.”
But the last word died away in deadly faintness. Mr
Cunningham gave a hasty call. Robertson came out of the
house, and Alwyn could do nothing but help to carry his
brother into his room. He could not go till Edgar revived,
which was not for some time, and then it was hardly to full
consciousness, certainly not to his ordinary self-control, for
he clung to Alwyn’s hand, entreating him not to leave him.
“Don’t go, Alwyn, don’t! You know I can’t come to you—you
know I can’t come to the wood to-day.”
“Can you say nothing to quiet him, sir?” whispered
Robertson. “He has no strength for such excitement. His
heart is very weak.”
“I shall stay,” said Alwyn; “don’t fret, my dear boy; indeed,
I won’t leave you now.”
“You know that I’ll never take your place; even if I live I will
not!” said Edgar vehemently.
37. “No, no,” said Alwyn, without much perception of the sense
of what Edgar was saying. “Never mind it now. There, that’s
better. Hush! we will talk by-and-by.”
Edgar grew quieter at last, and Alwyn, as he sat beside him,
began a little to realise the situation. His father had retired
as soon as the first alarm was over, and no word came from
him.
Presently some soup was brought for Edgar, and Robertson
deferentially offered Alwyn a tray with sandwiches and
some claret.
“You will need it, sir, if you remain with Mr Edgar,” he said.
Alwyn hesitated, but he had had nothing since morning, and
for Edgar’s sake he must accept the situation in full. It was
a long strange night. Edgar was restless and feverish, only
soothed by Alwyn’s voice and touch; but towards morning
he fell asleep quietly, and Alwyn, as the sweet summer
morning dawned, looked round about him, and recognised
that the room in which he sat had been the old “study”—full
of how many memories! All the furniture was changed to
suit Edgar’s requirements, but the lines of the window, the
panels on the wall, had a strange familiarity. When Edgar,
half waking, looked at him, and murmured something about
a dream, Alwyn felt that either this night, or all the past
eight years, were as a dream to him. He heard the sounds
of the rousing household, familiar as no other sounds in the
world could be, and presently Robertson, who had gone to
lie down in the outer room, where he usually slept, came
back and said:
“Mr Cunningham has sent word, sir, to say that breakfast
will be served at nine in the dining-room. Will you let this
38. man show you a room? I think my young master will be
quite easy now.”
“I don’t like to leave him while he is asleep, he might wake
and miss me.—What, Edgar, awake? I am going to get some
breakfast; I shall be back soon.”
He spoke in as matter-of-course a voice as possible, and
Edgar only smiled a little and assented.
Alwyn went out into the new old house. The servants, who
came to him also with a curious new old deference,
unknown across the water, were strange to him; but he
almost laughed to see how, evidently, they accepted him,
and noticed that the man who had been attending on him
did not offer, when he came out, to show him the way to
the dining-room; he watched him as he turned naturally
towards it. The room was empty.
39. “Mr Cunningham begged you to take some breakfast, sir,
and to come to him afterwards in his library.”
Alwyn sat down and silently accepted the breakfast. He
recognised the gold-edged, deep-coloured china, the plate,
even the special variety of hot cakes which was offered to
40. him. He was too much absorbed to be embarrassed, and
was just deciding that it would be better to get the
interview with his father over before he saw Edgar again,
when a quick step sounded in the hall, and Geraldine stood
before him, her tall figure upright as a dart, and her dark
eyes recalling Edgar’s youth so vividly, that she seemed
more familiar to Alwyn than poor Edgar’s own altered
countenance.
He rose, colouring, and hardly knowing what to do; but
Geraldine walked straight up to him.
“Are you my brother Alwyn?” she said in her clear
outspoken voice.
“Yes—you are Geraldine?” said Alwyn.
“Why didn’t you tell me so in the wood? I am very glad you
are come home. I’ll be friends with you anyhow.”
Her bold, defiant voice sounded to Alwyn like an echo of his
own old self, and it struck him how ready both his father’s
children were to side against him.
Geraldine came close to him and offered to kiss him, and he
kissed her tenderly but very quietly, and looked at her as if
learning her face.
“I am very glad I have seen my sister,” he said. “But now I
must go to my father. I must not talk to you now.”
“I told Miss Hardman that I would come and speak to you,”
said Geraldine. “I shall write to you if you go away again. I
won’t be prevented.” Alwyn said nothing, and she looked at
length a little awed by his silence and gravity. He moved
away towards the door, then came back and kissed her
again, this time in a warm hasty fashion that brought the
41. tears to her eyes, then went across the hall and knocked at
the door of his father’s library.
42. Chapter Sixteen.
Harry Again.
Harry Whittaker, when suddenly claimed by Florrie as her
long-lost brother, felt an immediate sense of recognition of
the fair, fat, bouncing-ball of a seven years child, whom he
remembered in the equally bouncing and fully proportioned
damsel of fifteen.
“If you’re my little sister Florrie,” he said, taking hold of her
hands, “how do you come to be out here by yourself at this
time in the evening?”
“’Twas I went and chattered to the keepers and set ’em
upon you. And when little Miss Lily found this here letter, I
knew as how it was you and Miss Geraldine’s brother, and I
run away to tell Wyn to stop ’em.”
“Run away from the Warrens?”
“No—from Ravenshurst; I was to help the nurse there.”
“Run away from your situation!”
“Well,” said Florrie with more spirit, “it was a deal better to
run away than have you put in prison. I ain’t so set on
situations, either.”
“Well, Florence, you’re a plucky girl I see, and I’m greatly
obliged to you; but now I must just take you back to the
keeper’s lodge, that they may be able to say to the lady
that your own brother brought you home again.”
43. He gave a little squeeze to the hand he held, which brought
a curious thrill to Florence’s heart. “But—but won’t they
take you up?” she said.
“No; I shan’t play hide-and-seek any longer. Anyway, if you
came out to take care of me I’m bound to take care of you.
So come along.”
“I ain’t afraid to go back to Ravenshurst and face it out,”
said Florrie.
“No; you shall go back with a good account to give of
yourself to-morrow, and now you do as I tell you.”
Harry was so uneasy as to what had become of Mr Alwyn
that he was not sorry for any chance of finding out.
Florence walked along by his side more subdued than she
had ever been in her life. She answered all the various
questions which Harry asked her about home and their
father quite meekly and as they neared the keeper’s lodge,
to which he knew the way much better than she did, he
heard a little sniffle.
“Don’t be afraid, I’ll stand by you,” said Harry good-
naturedly, and Florence for once did not reply that she
never was afraid in her life.
There was a light still burning in the lodge, and Harry went
boldly up and knocked at the door. It was opened by
Charles Warren himself, who looked the tall burly figure up
and down.
“If you’re Henry Whittaker,” he said, “walk in, and we’ll hear
what you’ve got to say.”
44. “I thank you kindly,” said Harry; “I shouldn’t have intruded,
but I’ve brought back my sister, who—”
“Mercy on us, Florrie!” exclaimed Mrs Warren, coming
forward, while Wyn, looking very pale and red-eyed, with a
large patch of brown paper on his nose, almost fell upon
Florence.
“Oh, Florrie I have they sent you home in disgrace, for—for
thinking Mr Alwyn was a poacher? It’s all over now, and
we’ve been the ruin of everything, and Mr Edgar’s heart will
be broke, and all through me.”
“It ain’t ruined at all,” said Florence, “and I’ve found the
letter for you, and here it is.”
“That’s nothing near so bad as the other letter what
master’s got!” said poor Wyn.
“Now shut up, Wyn,” said his father. “Mr Alwyn’s at the
house, and the matter’s out of your hands, which never
ought to have been mixed up in it. Get you to bed at once.
And what has brought Florence back again?”
“I went and carried on with Jim Blake and young Benson,
and I set ’em on thinking the men in the wood were
poachers, and when I found the letter in Miss Lily’s pocket,
and saw it was Mr Alwyn and my brother, I thought I’d
better run away than have their deaths on my shoulders.
But I was settling down, Aunt Charlotte, I was indeed, and
folding up the clothes quite regular.”
“Could a note be sent to tell the lady what is become of
her?” said Harry. “I’ll go myself if that’s all; but it’s late,
perhaps, to disturb them with a long story.”
45. “I’ll take the note,” said Ned Warren, who had been
standing in the background, “if Bessie ’ll write it.”
Bessie accordingly indited a note in her mother’s name, in
which she begged to inform her ladyship that Florence
Whittaker had come home, but that circumstances had
occurred in part to excuse her and that she (Mrs Warren)
would wait on her ladyship the next morning with a full
explanation.
This note despatched, Bessie good-naturedly went upstairs
to bathe Wyn’s face and to hear Florence’s story, and to
leave the elders free to come to an explanation with the
returned stranger. “Would you be good enough,” said Harry,
“to tell me what has occurred as to Mr Cunningham?”
“It’s just this,” said Charles Warren. “Strangers are scarce in
these parts, and my boy and the girl took it into their heads
as they must be after mischief, and chattered about what
was none of their business to the two young fellows that
Ned and I have got in to help us. So when they saw a
stranger, as they expressed it, ferreting in a tree, they
clapped him on the shoulder and asked him his business.
He looked them in the face, as they put it, as cool as you
please, and asked them if they thought he was looking for
pheasants’ eggs in a hollow tree in August? Which they took
for cheek, which it sounded like, and told him they’d walk
him up here to me. So he says, says they, ‘I’m glad you
mind your business so thoroughly. Just walk up to the
house with me, and I’ll explain matters to Mr Cunningham
myself.’ So they walked him up, and Jim Blake, who has the
most gumption of the two, says he did begin to feel
uncommon uncomfortable, and when they came to the
garden side, there was the master on the terrace. So says
their man, ‘There’s your master, alone, I think. We’ll go and
speak to him at once.’ And he unlatched the gate, quite
46. natural-like, and walks up to the terrace. And there they
saw Mr Edgar lying, and he gave a start and held out his
hands, and the master sent them off with a flea in the ear.
And they come straight to me, full of misgivings; they’re
new in these parts, but, of course, I knew who it must be at
once.”
“It did sound like Mr Alwyn all over,” said Mrs Warren.
“Then back comes Wyn, and hears the story, and begins to
cry, and bursts out about the letter that Mr Alwyn had given
him and the master took.”
“And is Mr Alwyn at the house now?” asked Harry.
“Yes,” said Warren, “he is. But now, perhaps, you’ll tell us
where you come from, and what’s brought you here, and
why in the wood?”
“That last,” said Harry, “came about unfortunate. Mr Alwyn
and I came down here straight from London, knowing
nothing of any one. And, thinking I was least likely to be
recognised, he sent me with the letter to his brother, asking
him to meet him in the wood, or come to London to see
him, and to tell him how the land lay before he made
himself known to his father. I gave the letter to Wyn, who
dropped it: here it is. Mr Alwyn met Mr Edgar by chance,
and was so knocked down by the state in which he found
him, that he couldn’t tell what to do next. He was afraid,
you see, of his brother having to bear the brunt of a
discovery, and he not there. That made him delay.”
“But, why hollow trees, which seem to have occurred in
everybody’s story?” said Warren.
“Oh!” said Harry, “to pass the time,” repeating much of what
he had told Mrs Stroud, omitting, however, Alwyn’s
47. experiences, but showing the copies of the certificates and
attestations of Lennox’s confession, giving proofs by letters
and documents of his respectable position in the States,
and expressing with the frankness which, while it was like
his old daring, had yet a different note in it, how, being a
father himself, he had repented of his hardness and neglect
towards his home. “But,” he concluded, “if people don’t
believe us, there’s no more to be said about it at present.”
Warren was a shrewd man; he had never thought it at all
likely that Harry had stolen the jewels, and he saw plainly
that there was no reason to induce him to return to his
native country unless the story was true.
“I take it,” he said, “that the gentlemen before whom these
affidavits were made believed in the story.”
“Why, certainly,” said Harry, “which they are prepared to say
in writing. Mr Warren,” he added, standing up, “there’s a
deal in the past I have to ask your pardon for. I was a
young scamp that cared neither for man nor God, and I was
downright ungrateful for all your kindness. But I’m clear
from that theft, and if you and my father can say you think
so, you’ll clear away a trouble from me which not all my
good fortune has made me forget.”
“Well, Harry,” said Warren, “I see nothing against your
story, and I’m prepared to help you to make it out.”
After this Bessie came down, and the conversation took an
easier turn, the exhibition of the family photograph, with
the well-dressed wife and comfortable baby, having its due
effect on Mrs Warren. A shakedown was offered to Harry in
the kitchen, and at a late hour they all went to bed, if not to
sleep, after the day’s excitement.
48. The next morning, as Wyn, though he was still rather sick
and headachy, and anything but presentable, was preparing
to go about his work and to inquire for Mr Edgar, and as Mrs
Warren was making Florence tidy, in Bessie’s hat, to
accompany her on a penitential errand to Ravenshurst,
there was a tap at the open door, and there stood Alwyn
Cunningham himself, as Mrs Warren said afterwards, for all
the world as if he had come to give his orders for a day’s
shooting.
“I heard you were here, Harry,” he said, grasping his
comrade’s hand. “Warren, I hope you’ll give me a welcome
also.”
“Indeed I will, sir, and glad to see you. Hope you’ll overlook
the young fellow’s mistake yesterday.”
Alwyn laughed a little.
“They were quite in the right of it,” he said. “Hullo, Wyn,
you have punished yourself as well as the horse.”
“Please, sir, if I hadn’t been stupid-like with my nose
bleeding, I’d never have give up the letter. I’d have eaten it
first!” burst out Wyn miserably.
“It was all for the best,” said Alwyn, “and you’re a faithful
little fellow.”
He paused a moment, then went on, aside to Harry:
“My father wishes me to remain here for the present, and
he will give facilities for the search in the wood which we
wished to make. What are your plans, Harry?”
“Well, sir, since things are settled here, I think I ought to go
to Rapley.”
49. “Can you go to London as well, and give orders for my
things to be sent here? I could telegraph, but they are all in
confusion. I don’t wish to leave my brother to-day. And you
know I must not delay in going to Ravenshurst.”
“Is Mr Edgar better, sir?” asked Wyn timidly. “Not much, I’m
afraid, as yet. He must be very quiet for the present.”
“Is all right, Mr Alwyn?” said Harry, as he followed him out
of doors.
“As right as may be. My father acknowledges me, and asks
me to stay with him. Friendliness and forgiveness are
another matter. He read and heard all I had to say, and I
believe he thinks your character cleared. Perhaps the
sudden meeting was as well for him as any other, but poor
Edgar fainted; all plans and scruples had to give way. It has
been a terrible shock for him, and he is quite worn out, only
wanting to keep me in sight I’ll go back to him. I can’t think
of anything else just now.”
He turned off with a hasty “Good morning.”
“He’s as grave as his father,” said Mrs Warren, “only the
master never spoke so gentle. Well, I’d like to have seen Mr
Alwyn’s merry face again.”
“When folks have to right themselves after they’ve gone as
wrong as Mr Alwyn and I did,” said Harry, “there ain’t so
much merry-making left in them. Not but what a light
heart, thank God, is very persevering. And Mr Alwyn’s got a
twinkle in him yet. But coming home’s bitter hard to him,
and everybody ain’t as forgiving as you, Cousin Charlotte,
nor as comfortable to ask pardon of.”
50. Chapter Seventeen.
To Set Wrongs Right.
The abrupt disappearance of the new nursemaid had
naturally caused considerable excitement at Ravenshurst,
and Lily’s story, when she was asked to repeat what the
new girl had said to her, did not throw much light on the
subject. It seemed, however, to be clear that the child had
really picked up a letter in the forest, and that, on its being
shown to Florence, the girl had at once decamped. When
Mrs Warren’s note came, promising an explanation, Sir
Philip Carleton hummed and hawed, but told his wife that,
as Cunningham’s keeper’s wife seemed so respectable a
person, she had better hear the explanation. As to taking
the girl back, that was another thing altogether.
Lady Carleton had no idea what the explanation was to be,
and when Mrs Warren appeared at the door of her morning-
room with Florence behind, hanging her head, her reception
was not encouraging.
“I hope, Mrs Warren, that you have some reason to give for
your niece’s extraordinary conduct. She has behaved in a
most unheard-of manner.”
“She has, my lady, and I am going to trouble your ladyship
with the excuse for it. Some strangers were seen in the
wood, and Florence here and my little boy took it into their
heads, which was none of their business, to warn the
keepers about them. Then, my lady, when Florence was
putting Miss Lily to bed, the little lady showed her a letter
which she said she had found in the wood.”
51. “Yes,” said Lady Carleton; “Miss Lily told me something
about that letter, but I had no time to attend to her. Well?”
“My lady, she saw in that letter the name of her own
brother, Harry Whittaker, and perceived it was written by Mr
Alwyn Cunningham, whose story, my lady, she had heard, it
seems, from my Wyn. And Florence put two and two
together, and saw that ’twas her own brother and Mr Alwyn
that she had set the keepers upon, and off she ran, without
another thought to send Wyn to warn them. And indeed, my
lady, I hardly know whether it was her place or not; certain
sure she ought to have mentioned that she was going; but
her brother met her and brought her home; and if your
ladyship can overlook her behaviour, she’ll be a good girl for
the future, I do think.”
“But, Mrs Warren,” exclaimed Lady Carleton, to whom
Florence’s conduct was the least part of the matter, “do you
mean to say that Mr Alwyn Cunningham has returned?”
“Yes, my lady, he has, and Henry Whittaker too; and I may
say, your ladyship, that Henry appears to be a reformed
character, and well-to-do also. And very remarkable things
he had to tell us. But those it is not my business to trouble
your ladyship with.”
Mrs Warren said no word about the confession and the
jewels; that, she thought, was not her business. And now
that Mr Alwyn was once more in his proper place, she had
no call to discuss his character.
“Of course, my lady,” she said, “if your ladyship feels that
you cannot overlook such a breach of propriety, I will take
Florence back at once.”
Lady Carleton looked at the girl for a moment.
52. “I should like Florence to stay,” she said. “Will you please
leave her with me now, Mrs Warren? I see that the case was
exceptional.” Mrs Warren thanked her ladyship, and with a
discreet hope that Florence would be grateful and obedient,
withdrew at once.
“Come here, Florence,” said Lady Carleton in the softest
voice Florence had ever heard. “It was a very serious thing
to do, you know, to run away without leave. It is because I
think that you are a good steady girl in general that I
overlook it, as you had a reason.”
“I ain’t a good girl, Lady Carleton,” said Florence. “I ain’t
steady, but I wasn’t after nothing wrong last night.”
“What do you mean by saying you are not steady?” said
Lady Carleton, somewhat taken aback by Florence’s town-
bred use of her name and by her queer manner.
“I was always the one to lead the rest,” said Florence, “and
I’ve always liked a bit of fun. But I had to go and try to step
them from taking Harry up for a poacher, and—and he says
it ain’t no manner of use to say ‘Don’t care,’ and I’m very
sorry.”
“If you were able to stop the harm you had begun to do,
that is a thing to be very thankful for—to thank God for!”
said Lady Carleton with some emotion in her tone.
Florence looked up with a certain solemnity in her round
eyes never seen there before.
“I did say my prayers in the wood,” she said, “when I lost
my way, and then Harry came.”
“Tell me about it,” said Lady Carleton kindly. Thus
encouraged, Florence volubly, according to her nature, but
53. with a friendliness of manner which was really the nearest
approach to respect that she had ever exhibited, told her
tale.
“And my heart was in my mouth, ma’am, the trees were
that black and that awful. I’d have run back, for I wouldn’t
have cared if nurse had given me ever so much of the
rough side of her tongue. But there, I couldn’t have it on
my mind that I’d set the keepers on my brother and dear
Miss Geraldine’s too. But I didn’t know one path from
another no more than if there hadn’t been none. And then I
thought of little Miss Lily’s prayer about setting wrongs right
and travellers, and I said it, Lady Carleton; and there was
Harry.”
“Did you, Florence? Oh, thank God for it!” said Lady
Carleton tearfully.
“And he took me right back, and he said this morning that
the best thing I could do was to come back here and be
trained a bit. And so I’ve come, please, ma’am—my lady.
Please, aunt said I was to say ‘my lady,’ and I will, but I
forgot; and I’ll be a good girl, and not gossip on the sly, nor
answer nurse back, nor make the other girls saucy. And I’ll
trim up my hat quiet, if you like, my lady. I—I want to be
good.”
Florence cried as she finished speaking, and wiped her eyes
and blew her nose noisily. Perhaps, but for the
circumstances that appealed so strongly to her sympathy,
Lady Carleton would never have recognised how real this
confused desire “to be good” was in this extraordinary girl,
so unlike any well-trained maiden whom she had ever
encountered.
54. “Well,” she said, “you shall try. You had better talk as little
about the matter as possible, and I trust you never will
‘gossip on the sly,’ or do anything of the kind, for I couldn’t
have a girl who was not nice and modest near my little
ones. I will speak to nurse.”
“Thank you—my lady.”
But as Lady Carleton rose to take her back to the nursery,
Florence’s round face suddenly beamed all over, and she
said sympathetically: “They’ve found out who stole the
jewels, my lady, and it was not Harry nor Mr Alwyn. They
were as innocent as lambs.”
“I think we had better not talk about that just now,” said
Lady Carleton; and then, with a sudden inspiration and
effort, she added: “Florence, perhaps you don’t know that it
was partly my fault that those jewels were lost, that I
helped to put some one in the way of temptation. It was
because I was so silly, that I only thought of what you call
‘a bit of fun.’ That is why I was so glad you were able to
prevent the mischief you started, and why I taught Miss Lily
to say those prayers. The good God has heard them. You
see, I shall be very glad if you are good.”
Lady Carleton had a very simple manner, but Florence
looked up at her with the first sense of real respect—she
had begun to have real likings—that she had ever known.
“I will try,” she said softly, with her bold eyes cast down;
and Lady Carleton took her by the hand and led her up to
the nursery.
An hour or two later, when Florence, whose reception by the
nurse had not been particularly cordial, was sitting
demurely in the nursery window, putting her best
needlework, such as it was, into Miss Lily’s new pinafore, a
55. note was brought to Lady Carleton. “The gentleman was
waiting.” Lady Carleton had thought of nothing but the half-
heard story of the returned travellers, of the hint about the
jewels, and of the hope that the consequences of her girlish
folly might be undone at last.
The note ran thus:—
“Ashcroft: August 5th.
“Dear Lady, Carleton,—My eldest son has returned from
abroad. He asks your permission for a short interview,
either with yourself or with Sir Philip Carleton, concerning
the circumstances under which he left England.
“I remain sincerely yours,—
“George Cunningham.”
Lady Carleton handed the note to her husband, to whom
she had already related Florence’s story.
“You will see him?” said Sir Philip. “Ask the gentleman to
walk in.”
It was a very uncomfortable moment both for Lady Carleton
and for Alwyn Cunningham, who had been boy and girl
together, and now hardly knew how to meet; but Sir Philip
carried it off by ordinary greetings as to the son of a
neighbour, whose acquaintance he was ready to make, and
Alwyn hardly waited a moment before he entered on the
matter in hand.
He took out the jewel that he had shown to Edgar in the
wood and laid it on the table.
56. “I can at least return to you this piece of your family
property, Lady Carleton,” he said.
“My mother’s jewel, the ruby bird!” faltered Lady Carleton,
hardly knowing what this implied.
“And,” said Alwyn, “I will ask Sir Philip Carleton to be good
enough to read these papers.”
These contained the confession of Lennox, already alluded
to by Harry Whittaker to his aunt, and the attestations of it,
of which he had shown copies to the Warrens.
“That Lennox stole the jewels, and returned one of them on
his death-bed to me, Whittaker has told some of his
relations,” said Alwyn, “but the main fact of the matter has
only been confided to my father, as you will see that it
would not do to make it public. This Is the substance of
what he told me as nearly as possible in his own words:
”‘I put the jewels for safety in a hollow tree near the
entrance to Ravenshurst. I thought they were safer there
than in my keeping. I kept one back to take it up to London,
and see if I could dispose of it, but before I could do so the
alarm was given. I was afraid to come back without a
reason, and I went off with my new master, leaving the
jewels in the tree, and thinking they’d either be found (I
have never been in England since), or I should get a chance
of coming back for them. But I put it off and I put it off. I
took service with Mr Alwyn Cunningham because I thought I
could find out how things had gone; and I hope he will go
home and find the jewels.’”
“This is a most extraordinary story,” said Sir Philip.
“It is,” said Alwyn. “Of course it rests finally on the
unsupported words of myself and Whittaker, who alone
57. heard it. These other papers and letters may show what
worth is attached to our words in our own neighbourhood,
but that is all.”
“Then do you mean to say,” ejaculated Sir Philip, “that these
missing jewels are—are in an old tree trunk in Ashcroft
Wood?”
“Well,” said Alwyn, “all I can say is that Lennox said that he
put them in one.”
“Good heavens!” exclaimed Sir Philip.
“But, of course,” Alwyn continued, “some one may have
lighted on them during these eight years and carried them
off, to say nothing of the difficulty of finding them. For he
had done it, he said, in the dark, and though he could have
found the tree himself, he could not tell me anything about
it, except that it was near Ravenshurst. You see he was
dying fast, and spoke with great difficulty.”
“Do you remember the man, Lily?” asked Sir Philip.
“I think I remember something about a servant who went to
America. Oh, Philip, you will have every place searched—
you will help Mr Cunningham? If the jewels could be found!
But I don’t mind so much after all about that if no one is
accused falsely.”
“As to that,” said Sir Philip, “I know Mr Dallas, of Boston,
and the Bishop of. I knew them when I was once in the
States, the year before I married. What they say here is
quite sufficient to establish the worth of Mr Alwyn
Cunningham’s testimony and the character of his foreman,
who is more concerned in the matter. You will allow me to
call on you, Mr Cunningham, and to express my pleasure at
your return.”
58. “Thank you,” said Alwyn, a little stiffly, for the situation
sorely tried his pride. “I am much obliged to you,” he
added, after a moment.
“And, Alwyn,” said Lady Carleton, with tears in her eyes,
“can you ever forgive me for my silly trick, and for being too
frightened to tell of it at once? Oh, I have never—never
forgiven myself.”
“I don’t think it is easy for any of us to forgive ourselves,
Lady Carleton,” said Alwyn, “for that night’s work. But your
share was a very small one.”
“The fact is,” said Sir Philip, “the thing was never properly
investigated. Mr Fletcher was afraid that the silly trick would
come to my ears—too soon. I needn’t say—since you know
my wife—that I at once heard of it from her. The chance
was lost. But what is to be done now? You yourself believe
this story?”
“Oh yes,” said Alwyn, “I do. There was no object in
deceiving me. No; I am sure Lennox had not sold the
jewels, and made up the story of the old tree.”
“We cannot let it get about that the wood is full of
diamonds,” said Sir Philip.
“No,” returned Alwyn with a laugh; “neither Whittaker nor
myself could resist a little bird’s-nesting, but it was, of
course, unwise. That was partly why I wished to make
myself known first to my brother. I did not know then that
part of our misfortunes.”
“Ah! poor fellow,” said Sir Philip, “he is sadly helpless. But
your return will be a capital thing for him. His life must be
rather solitary.”
59. “Yes, I fear so,” said Alwyn. “I will go back to him now, with
many thanks for a most kind reception.”
“Lily,” said Sir Philip, when their guest was gone, “I believe
young Cunningham told the truth and the whole truth, to-
day. But I didn’t.”
“What in the world do you mean, Philip?”
“Why, only yesterday I got a letter from old Dallas, giving a
wonderful account of him and his high character out there,
but wanting naturally to know how Mr Cunningham’s eldest
son came to be there at all. I was wondering what I could
say, for it was very evident that he had a reason for asking
—there’s a lady in question, I imagine—when to-day he
turns up.”
“Oh, Philip, we must find the jewels!”
“We must; but it passes me to know how to set about it.”
60. Chapter Eighteen.
Sunday at Home.
On the next Sunday morning the bells of Ashcroft Church
were ringing for an early celebration of the Holy
Communion. Many eyes were turned on Alwyn Cunningham
as he walked down the village in the fresh sweetness of the
summer morning. Such early church-going was not
according to Mr Cunningham’s habits, and probably Alwyn
was the last person that any one expected to see practise it,
for the formal confirmation of a careless public schoolboy
had never been followed up, and in old days he had never
been a communicant. The change from former habits was
so marked that the conservative villagers of Ashcroft looked
at him very distrustfully, as if they wondered why he came.
Perhaps Alwyn had forgotten what it was to be the observed
of all observers; perhaps he had learnt that only thus would
he obtain the help he needed in a most painful position. His
father had accepted his statements as to Lennox’s
confession, and had allowed such a search for the jewels as
could be made without publicity to be commenced at once.
He also acknowledged in a more indirect way that his son
had become a respectable member of society, fit to visit at
his house; but he did not open his heart to him, nor forgive
him, except in a formal manner. Alwyn felt that his father
did not trust him, he knew that his engagement to an
American lady would not tell in his favour, and he guessed
that the marked and complete change of attitude as to
religious matters, the account of which, indeed, had been
intended for Edgar only, would be viewed with suspicion. Mr
Cunningham, after reading the letter, had touched on no
point but the lost jewels, and Alwyn had accepted his
61. silence and the situation, and talked diligently when they
met, and at meal times, of general topics.
But when old Mr Murray saw him this morning he wondered
if the inaccessible Cunninghams, who had always been so
polite, and on such stiff term with him since his coming to
Ashcroft, would approached by the unlikely channel of the
returned exile.
Certainty anything less like the irreverent, light-minded
youth whom he had heard described than Alwyn’s serious
face could hardly be imagined, and Bessie Warren could not
help wondering what he was thinking of, as she saw him
look round before he turned away, as if noting the once
familiar scene.
Edgar had been so weak and so much shaken by all that
had passed that he had been content to take his brother’s
presence for granted, and when Alwyn realised how very
solitary such hours of languor and suffering must usually
have been, he cared little what his presence there cost
himself, if the sight of him made Edgar’s eye brighten and
gave him any pleasure, however small.
To-day, however, Edgar was better, and his interest and
curiosity began to revive. He had been lifted on to his couch
by the open window, and had sent a message to Wyn to
bring his black eyes to be looked at, and after a little space
of the eager watching of the outdoor world that was always
so much to him, he said to Alwyn:
“Where is that letter that you wrote for me? I could read it
now, and I’m as much in the dark as the first day I saw
you.”
“Here it is,” said Alwyn; “shall I read it to you or tell you
about it? Is your head well enough to read it?”
62. “Oh yes; I can stop if I’m tired. I had rather have it.”
Alwyn gave him the letter, and went on with the one that he
was himself writing, while Edgar studied the long document
for some time in silence.
Presently Edgar talked a little about the jewels and the
chances of their discovery, observing that whoever poked
about in the dark or on the quiet, hunting for them, would
certainly get shot by the zealous keepers who had laid
hands on Alwyn.
“There’s nothing for it but setting the forest on fire,” he
said.
“No, no,” said Alwyn, “the jewels are not worth a tree of it.”
Edgar gave him one of his keen glances, under which the
colour mounted to Alwyn’s brow.
“My father has given Warren orders to be thorough over it,”
he said.
Edgar said nothing, and returned to the letter.
“Are—are you writing to Miss Dallas?” he said presently,
with a rather shy intonation.
“No; I have not that privilege. To her brother.”
“Tell me about her. What’s her name?” said Edgar.
Alwyn was nothing loath.
“Corinne is her name,” he said; “they use it in America.”
And then he went on and told Edgar a great deal, for which
there is no space in this story, and as he talked his face
grew happy and eager, and Edgar listened a little wistfully.
63. 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!
ebookname.com